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

Fix issue with EXTENDS using private repository by sending GITHUB_TOKEN as HTTP auth header #3404

Merged
merged 4 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
- Trivy: use `misconfig` instead of the deprecated `config` scanner, updating the default arguments
- Update calls to sfdx-scanner to output a CSV file for Aura & LWC
- Kics: fixed error count in the summary table
- Fix issue with EXTENDS using private repository by sending GITHUB_TOKEN as HTTP auth header
- Fix SPELL_VALE_CONFIG_FILE not working (handle the override of linter CONFIG_FILE if the linter is activated only if some files are found)

- Doc
Expand Down
9 changes: 8 additions & 1 deletion megalinter/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,14 @@ def combine_config(workspace, config, combined_config, config_source):
extends = extends.split(",")
for extends_item in extends:
if extends_item.startswith("http"):
r = requests.get(extends_item, allow_redirects=True)
headers = {}
if (
extends_item.startswith("https://raw.githubusercontent.com")
and "GITHUB_TOKEN" in os.environ
):
github_token = os.environ["GITHUB_TOKEN"]
headers["Authorization"] = f"token {github_token}"
r = requests.get(extends_item, allow_redirects=True, headers=headers)
assert (
r.status_code == 200
), f"Unable to retrieve EXTENDS config file {extends_item}"
Expand Down
Loading