Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflows: Add Code Scanning action, fix up failures #13149

Merged
merged 8 commits into from
Apr 18, 2022
2 changes: 2 additions & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
paths-ignore:
- Library/Homebrew/vendor/
36 changes: 36 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
issyl0 marked this conversation as resolved.
Show resolved Hide resolved
schedule:
- cron: '30 2 * * 0'
issyl0 marked this conversation as resolved.
Show resolved Hide resolved

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
issyl0 marked this conversation as resolved.
Show resolved Hide resolved
matrix:
language: [ 'ruby' ]
issyl0 marked this conversation as resolved.
Show resolved Hide resolved

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
8 changes: 4 additions & 4 deletions Library/Homebrew/dev-cmd/bump-formula-pr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,13 +383,13 @@ def determine_formula_from_url(url)

def determine_mirror(url)
case url
when %r{.*ftp.gnu.org/gnu.*}
when %r{.*ftp\.gnu\.org/gnu.*}
url.sub "ftp.gnu.org/gnu", "ftpmirror.gnu.org"
when %r{.*download.savannah.gnu.org/*}
when %r{.*download\.savannah\.gnu\.org/*}
url.sub "download.savannah.gnu.org", "download-mirror.savannah.gnu.org"
when %r{.*www.apache.org/dyn/closer.lua\?path=.*}
when %r{.*www\.apache\.org/dyn/closer\.lua\?path=.*}
url.sub "www.apache.org/dyn/closer.lua?path=", "archive.apache.org/dist/"
when %r{.*mirrors.ocf.berkeley.edu/debian.*}
when %r{.*mirrors\.ocf\.berkeley\.edu/debian.*}
url.sub "mirrors.ocf.berkeley.edu/debian", "mirrorservice.org/sites/ftp.debian.org/debian"
end
end
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/download_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1404,18 +1404,18 @@ def self.detect_from_url(url)
when %r{^https?://www\.apache\.org/dyn/closer\.cgi},
%r{^https?://www\.apache\.org/dyn/closer\.lua}
CurlApacheMirrorDownloadStrategy
when %r{^https?://(.+?\.)?googlecode\.com/svn},
when %r{^https?://([A-Za-z0-9\-.]+\.)?googlecode\.com/svn},
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved
%r{^https?://svn\.},
%r{^svn://},
%r{^svn\+http://},
%r{^http://svn\.apache\.org/repos/},
%r{^https?://(.+?\.)?sourceforge\.net/svnroot/}
%r{^https?://([A-Za-z0-9\-.]+\.)?sourceforge\.net/svnroot/}
SubversionDownloadStrategy
when %r{^cvs://}
CVSDownloadStrategy
when %r{^hg://},
%r{^https?://(.+?\.)?googlecode\.com/hg},
%r{^https?://(.+?\.)?sourceforge\.net/hgweb/}
%r{^https?://([A-Za-z0-9\-.]+\.)?googlecode\.com/hg},
%r{^https?://([A-Za-z0-9\-.]+\.)?sourceforge\.net/hgweb/}
MercurialDownloadStrategy
when %r{^bzr://}
BazaarDownloadStrategy
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/rubocops/homepage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
when
# Check for http:// GitHub homepage URLs, https:// is preferred.
# Note: only check homepages that are repo pages, not *.github.com hosts
%r{^http://github.com/},
%r{^http://github\.com/},
%r{^http://[^/]*\.github\.io/},

# Savannah has full SSL/TLS support but no auto-redirect.
# Doesn't apply to the download URLs, only the homepage.
%r{^http://savannah.nongnu.org/},
%r{^http://savannah\.nongnu\.org/},

%r{^http://[^/]*\.sourceforge\.io/},
# There's an auto-redirect here, but this mistake is incredibly common too.
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/rubocops/urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
end

# GNU URLs; doesn't apply to mirrors
gnu_pattern = %r{^(?:https?|ftp)://ftpmirror.gnu.org/(.*)}
gnu_pattern = %r{^(?:https?|ftp)://ftpmirror\.gnu\.org/(.*)}
audit_urls(urls, gnu_pattern) do |match, url|
problem "Please use \"https://ftp.gnu.org/gnu/#{match[1]}\" instead of #{url}."
end
Expand Down Expand Up @@ -177,7 +177,7 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
end

# Check for new-url Google Code download URLs, https:// is preferred
google_code_pattern = Regexp.union([%r{^http://.*\.googlecode\.com/files.*},
google_code_pattern = Regexp.union([%r{^http://[A-Za-z0-9\-.]*\.googlecode\.com/files.*},
%r{^http://code\.google\.com/}])
audit_urls(urls, google_code_pattern) do |_, url|
problem "Please use https:// for #{url}"
Expand Down Expand Up @@ -267,13 +267,13 @@ def audit_formula(_node, _class_node, _parent_class_node, body_node)
urls += mirrors

# Check pypi URLs
pypi_pattern = %r{^https?://pypi.python.org/}
pypi_pattern = %r{^https?://pypi\.python\.org/}
audit_urls(urls, pypi_pattern) do |_, url|
problem "use the `Source` url found on PyPI downloads page (`#{get_pypi_url(url)}`)"
end

# Require long files.pythonhosted.org URLs
pythonhosted_pattern = %r{^https?://files.pythonhosted.org/packages/source/}
pythonhosted_pattern = %r{^https?://files\.pythonhosted\.org/packages/source/}
audit_urls(urls, pythonhosted_pattern) do |_, url|
problem "use the `Source` url found on PyPI downloads page (`#{get_pypi_url(url)}`)"
end
Expand Down