444 Commits

Author SHA1 Message Date
Xu Cheng
12c505c093
audit: avoid unnecessary regex
Regex is way slower than normal String#include? and String#start_with?.
Also, we often forget to proper escape them. So avoid using them if it
is not necessary.

Closes #503.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-07-13 19:11:47 +08:00
Xu Cheng
de1049f1f1
various: proper escape dot in regex 2016-07-13 19:11:46 +08:00
Xu Cheng
91fb49d270
various: proper escape in regex 2016-07-13 19:11:46 +08:00
Dominyk Tiller
706b06942f
audit: update ruby dependency advice
Closes #495.

Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
2016-07-13 04:55:59 +01:00
Dominyk Tiller
e9925d6177
audit: flag incorrect language/go requires 2016-07-10 21:26:39 +01:00
Viktor Szakats
df4982ed08 audit.rb: require https for download.savannah.gnu.org (#438)
and download-mirror.savannah.gnu.org
2016-07-10 01:43:27 +01:00
Viktor Szakats
6bd24a7fb8 audit.rb: require https for ftpmirror.gnu.org (#393)
* audit.rb: require https for ftpmirror.gnu.org

The situation is similar to other mirror redirectors: the server
may subsequently redirect to an insecure url. But it's a step.

* manpage: update HOMEBREW_NO_INSECURE_REDIRECT section
2016-06-22 18:56:10 +01:00
Martin Afanasjew
af42deca4a audit: detect more 'pkgshare' candidates (#328)
The new check also allows the `+` operator instead of our (still heavily
preferred) `/` operator for path concatenation and also triggers if the
operator is surrounded by whitespace.

Also recognizes single-quoted strings and uses a back reference to
match the closing quote for a slightly lower chance of false positives.

Closes #322.
2016-06-07 17:46:40 +02:00
Martin Afanasjew
1c00fed119 audit: check Maven Central URLs, prefer redirector (#311)
Should help with being more consistent and makes sure to suggest the
HTTPS redirector even if equally valid HTTP URLs for specific hosts or
`central.maven.org` are used.
2016-06-02 09:36:27 +02:00
Dominyk Tiller
0a7fcf2979
audit: appease rubocop
Closes #302.

Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
2016-05-31 13:33:09 +01:00
Dominyk Tiller
331fdba29d
audit: prefer https/s over ftp where known available
The FTP protocol is prone to getting firewalled to death in places, so where
we know we can avoid that by using either secure or more commonly accepted
protocols let's do so.

Examples of output:

```
* Stable: ftp://ftp.cpan.org/pub/CPAN/authors/id/N/NE/NEILB/Time-Duration-1.20.tar.gz should be `http://search.cpan.org/CPAN/authors/id/N/NE/NEILB/Time-Duration-1.20.tar.gz`
* Stable: Please use https:// for ftp://ftp.mirrorservice.org/sites/lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_4.89.tar.bz2
```
2016-05-31 13:32:47 +01:00
Dominyk Tiller
92e35705f8
audit: update mirrorservice check
mirrorservice accepts `http://ftp.mirrorservice.org` as well, apparently.
2016-05-31 13:32:47 +01:00
Dominyk Tiller
eaae49608f
audit: check for insecure metacpan urls 2016-05-31 13:32:47 +01:00
Dominyk Tiller
ff0f394f2e
Revert "audit: tweak cpan secure urls"
This reverts commit 7bbcf9cacc18aabf78a21ec5cc5892d440631e08.
2016-05-31 13:32:47 +01:00
Dominyk Tiller
9b7604df69
Revert "audit: tweak cpan secure urls"
This reverts commit 146a16d66bc796f0c6a4c7e2b88f1b73fb0aaa4c.
2016-05-31 13:32:47 +01:00
Mike McQuaid
01b6787aa8 audit: make system check stricter with quotes.
As mentioned in:
https://github.com/Homebrew/homebrew-core/pull/1396#discussion_r64774080
2016-05-29 22:52:26 +01:00
Tomasz Pajor
146a16d66b audit: tweak cpan secure urls 2016-05-29 11:07:19 +02:00
Tomasz Pajor
7bbcf9cacc audit: tweak cpan secure urls 2016-05-29 11:03:50 +02:00
Dominyk Tiller
56375a7b44 audit: minor spacing nit
Closes #248.

Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
2016-05-26 11:05:10 +01:00
Dominyk Tiller
2c6fa07e6d audit: tweak devel/head tap check
For some reason the existing check seems to have started failing between
March and today. I haven't managed to narrow down why yet but the biggest
change between then and now was the core separation so perhaps related to that.

Perhaps at some point we started considering purely short tap names,
i.e. homebrew/devel-only rather than full tap names, i.e. homebrew/homebrew-devel-only,
in the audit mechanism.

This fixes the current issue whilst retaining the spirit of the original commit:
86d04e94e9
2016-05-26 11:05:10 +01:00
Dominyk Tiller
a0d008af77 audit: enforce freedesktop secure urls 2016-05-20 10:54:29 +01:00
Mike McQuaid
e825f59754 audit: check for block inreplace with single sub. (#254)
There are unnecessarily verbose, have been documented to be avoided and
it’s good to nudge people towards the other style.
2016-05-19 20:38:46 +01:00
Mike McQuaid
b8e5ff431d audit: check more GitHub URLs. (#256)
GitHub’s code load and patch-diff URLs are the result of redirects and
make it harder to modify the URL to reach the original repository.
2016-05-19 07:56:11 +01:00
Andrew Janke
63ea9295cf brew audit: add --display-filename format option for easy grepping (#221) 2016-05-11 09:19:45 -07:00
Andrew Janke
2805531f13 audit: fix false-positive for '--with-check' from 'depends_on "check" => :optional' (#188)
Fixes #170
2016-05-03 08:16:20 -04:00
Martin Afanasjew
02289fce42 Update Homebrew/homebrew references in code
Replace `homebrew` with `brew`, `homebrew-core`, or `legacy-homebrew`
depending on context.
2016-05-02 21:19:09 +02:00
Christian Moritz
9378e46ffc audit: whitelist kibana from Language::Node check (#161) 2016-04-27 22:00:41 +01:00
Christian Moritz
bc98fd3788 Language::Node.npm_install_args: add helper method (#37)
* add Language::Node helper module

This adds a language module for Node module based formulas.
It contains the 2 public methods `std_npm_install_args(libexec)` and
`local_npm_install_args`:

* `std_npm_install_args` is intended to be used in formulas for
  standard node modules and returns `npm install` args for a global
  style module installation to libexec.
* `local_npm_install_args` is for formulas, in which the `npm install`
  step is only one of multiple parts of the installation process and
  returns `npm install` args for a default local installation in place.

Both methods have in common, that they are

* making sure that a working copy of npm and node-gyp from node's
  libexec is prepended to the PATH (to not rely of a user managed npm)
* seting the npm cache to HOMEBREW_CACHE/npm, which fixes issues caused
  by overriding $HOME resulting in long install times + high disk usage
  (see https://github.com/Homebrew/brew/pull/37#issuecomment-208840366)

* audit: update npm install check for Language::Node

* cleanup: remove npm_cache too

* doc: add Node-for-Formula-Authors.md
2016-04-27 17:08:44 +01:00
Andrew Janke
a3b70d38a7 brew-audit: pull style checks in to main audit output
This collects all violations for each formula in a single place, instead
of doing `brew style` outputs for all formulae first, and then the other
audit checks.

Closes #112.

Signed-off-by: Andrew Janke <andrew@apjanke.net>
2016-04-21 14:45:33 -04:00
Cory Donnelly
bad28dc546 audit.rb: Base desc length check on short name
Currently, brew audit --strict includes the name of the tap when calculating the
length of a formula's description. This makes it difficult to pass the audit for
formulas in taps with lengthy names. In #47033 @jawshooah called out head-only
or devel-only taps specifically, but this is an issue elsewhere. For example:

homebrew/versions/elasticsearch20: Distributed search & analytics engine (72)

This commit updates audit.rb to use formula.name rather than formula.full_name.

Closes #47033 -- Audit shouldn't include tap name in description length
2016-04-16 16:14:15 +02:00
Max Nordlund
fa1fd70a37 Add all the top level comments 2016-04-10 22:59:25 +02:00
Dominyk Tiller
a9c0361a1d audit: require plist_options when using plist
Closes #19.

Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
2016-04-05 23:57:53 +01:00
Dominyk Tiller
149334d88d audit: check plist placement 2016-04-05 23:57:53 +01:00
Xu Cheng
d0b713c396 Revert "lsyncd: use MACOS_FULL_VERSION"
This reverts commit 0f60f76f26ca9fe26e1c10c72905a878a58e3c96.
2016-04-03 23:19:38 +08:00
Xu Cheng
5bb8e8985d audit/test-bot/pull: fix for core/formula separation
All formulae are in taps now.
2016-04-02 21:51:36 +08:00
Baptiste Fontaine
236a18debe audit: fix crash when HOMEBREW_NO_GITHUB_API is set
Running brew audit --strict --online on a formula with a GitHub
homepage/url would crash if HOMEBREW_NO_GITHUB_API is set because
GitHub.repository returns `nil` and the audit code assumes it always
returns a hash.

Closes Homebrew/homebrew#50054.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
2016-03-14 19:39:15 +08:00
Xu Cheng
28f3dae8cd rename CoreFormulaRepository to CoreTap
Core tap will be separated from core code in the near future.
It makes sense to rename it to CoreTap.
2016-03-07 19:43:46 +08:00
Xu Cheng
b52af53e71 various: use Tap abstraction
formula_rename and tap_migrations are now handled inside Tap.

Closes Homebrew/homebrew#49549.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-02-26 17:00:17 +08:00
Mike McQuaid
b06c6c74f9 audit: roughly double notability requirements.
Closes Homebrew/homebrew#48706.
2016-02-11 20:32:22 +00:00
Misty De Meo
7b81066038 Audit: Regexp.escape formula names
We allow certain special regex characters in formula names, and if
those aren't escaped when interpolating them into a regex, they'll be
interpreted as special regex characters.

This can cause regex compile errors on Ruby 1.8 (for example, with
"libxml++3", which has nested match characters), and more subtle
matching bugs in general.

Refs an issue surfaced in Homebrew/homebrew#48744.

Closes Homebrew/homebrew#49005.

Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
2016-02-09 15:33:38 -08:00
Dominyk Tiller
58cf0ec2b9 audit: add check for insecure hackage urls 2016-02-04 14:57:55 +00:00
Baptiste Fontaine
cdd990f9d7 audit: use start_with? to check the name in the desc 2016-02-03 14:04:31 +01:00
Dominyk Tiller
557f6e33a9 audit: check resource placement 2016-01-31 00:39:29 +00:00
Baptiste Fontaine
e1875b7a43 audit: avoid false positive pkgshare problems 2016-01-25 17:19:51 +01:00
Baptiste Fontaine
e0c7b38aa7 audit: warn once about deprecated *Formula classes
GithubGistFormula inherits from ScriptFileFormula so a problem is added
for each one instead of the first only.
2016-01-25 01:26:24 +01:00
Xu Cheng
154d0850e7 audit_revision: only check 10 recent related commits
It helps to reduce overhead.

Closes Homebrew/homebrew#48108.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-01-17 14:52:15 +08:00
Xu Cheng
d4c7dedf12 audit: imporve revision check logic
* Check revision decrease against both stable and devel spec.
* Check revision reset only for stable spec if stable spec is available.
2016-01-17 14:52:14 +08:00
Xu Cheng
31da9b266a audit: enforce revision check
Add two checks:
* revision should be reset to 0 for new version.
* revision should not decrease inside the same version interval.

Closes Homebrew/homebrew#48032.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-01-14 15:26:21 +08:00
Xu Cheng
5f22586389 audit: check url/checksum/mirror outside of stable block
Closes Homebrew/homebrew#48033.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-01-14 13:35:36 +08:00
Dominyk Tiller
f4f2266923 audit: check for more unused shorthand
Adding a strict check for usage that should be using pkgshare.

Pulled onto two unique checks to provide a better problem message, with a
clearer solution, but open to thoughts.

 * Use pkgshare instead of (share/"example")
 * Use #{pkgshare} instead of #{share}/example

Closes Homebrew/homebrew#47900.

Signed-off-by: Dominyk Tiller <dominyktiller@gmail.com>
2016-01-11 09:49:54 +00:00