Skip to content

Commit

Permalink
Fix issue with EXTENDS using private repository by sending GITHUB_TOK…
Browse files Browse the repository at this point in the history
…EN as HTTP auth header (#3404)

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

Co-authored-by: Bheem <[email protected]>

* [MegaLinter] Apply linters fixes

---------

Co-authored-by: nvuillam <[email protected]>
Co-authored-by: Bheem <[email protected]>
Co-authored-by: nvuillam <[email protected]>
  • Loading branch information
4 people authored Mar 9, 2024
1 parent dafb4df commit 3efbff3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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

0 comments on commit 3efbff3

Please sign in to comment.