Skip to content

Commit 5b979e3

Browse files
authored
Merge branch 'main' into onboarding-automation
2 parents 0abbec5 + 1cdbc3b commit 5b979e3

File tree

15 files changed

+393
-30
lines changed

15 files changed

+393
-30
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,15 @@ jobs:
6262
fi
6363
6464
is-release:
65-
# Filtering by `push` events ensures that we only release from the `main` branch, which is a
66-
# requirement for our npm publishing environment.
67-
# The commit author should always be 'github-actions' for releases created by the
68-
# 'create-release-pr' workflow, so we filter by that as well to prevent accidentally
69-
# triggering a release.
70-
if: github.event_name == 'push' && startsWith(github.event.head_commit.author.name, 'github-actions')
65+
name: Determine whether this is a release merge commit
7166
needs: all-jobs-pass
67+
if: github.event_name == 'push'
68+
runs-on: ubuntu-latest
7269
outputs:
7370
IS_RELEASE: ${{ steps.is-release.outputs.IS_RELEASE }}
74-
runs-on: ubuntu-latest
7571
steps:
76-
- uses: MetaMask/action-is-release@v1
77-
id: is-release
72+
- id: is-release
73+
uses: MetaMask/action-is-release@v2
7874

7975
publish-release:
8076
needs: is-release

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [2.0.5]
11+
12+
### Added
13+
14+
- feat: add rule to catch npx usage in JS/TS/YAML
15+
16+
### Fixed
17+
18+
- fix: add .security-scanner directory to ignored paths
19+
1020
## [2.0.4]
1121

1222
### Changed
@@ -62,7 +72,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6272

6373
- Initial release of this action ([#29](https://github.com/MetaMask/action-security-code-scanner/pull/29))
6474

65-
[Unreleased]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.4...HEAD
75+
[Unreleased]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.5...HEAD
76+
[2.0.5]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.4...v2.0.5
6677
[2.0.4]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.3...v2.0.4
6778
[2.0.3]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.2...v2.0.3
6879
[2.0.2]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.1...v2.0.2

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/action-security-code-scanner",
3-
"version": "2.0.4",
3+
"version": "2.0.5",
44
"private": true,
55
"description": "Security Code Scanner",
66
"repository": {

packages/codeql-action/CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
## [2.0.3]
10+
## [2.0.5]
1111

1212
### Fixed
1313

14-
- Fix incorrect language selection based on repo config ([#63](https://github.com/MetaMask/action-security-code-scanner/pull/63))
14+
- fix: add .security-scanner directory to paths-ignore in CodeQL config
15+
16+
## [2.0.3]
1517

1618
### Fixed
1719

20+
- Fix incorrect language selection based on repo config ([#63](https://github.com/MetaMask/action-security-code-scanner/pull/63))
1821
- Fixed Codeql configuration build
1922

2023
## [2.0.1]
@@ -32,7 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3235
- Added multi language support
3336
- Updated CodeQL action to v4
3437

35-
[Unreleased]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.3...HEAD
38+
[Unreleased]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.5...HEAD
39+
[2.0.5]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.3...v2.0.5
3640
[2.0.3]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.1...v2.0.3
3741
[2.0.1]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.0...v2.0.1
3842
[2.0.0]: https://github.com/MetaMask/action-security-code-scanner/releases/tag/v2.0.0

packages/codeql-action/config/codeql-template.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: "Security Code Scanner CodeQL Config"
22

33
paths-ignore:
4+
- ".security-scanner/"
45
<% pathsIgnored.forEach(function(path) { -%>
56
- "<%- path %>"
67
<% }); -%>

packages/codeql-action/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/codeql-action",
3-
"version": "2.0.3",
3+
"version": "2.0.5",
44
"private": true,
55
"description": "Custom CodeQL analysis action",
66
"keywords": [],

packages/semgrep-action/CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [2.0.5]
11+
12+
### Fixed
13+
14+
- refactor: simplify Semgrep action by removing unnecessary file copy step
15+
- fix: update .semgrepignore to include .security-scanner directory
16+
17+
### Added
18+
19+
- feat: add rule to catch npx usage in JS/TS/YAML
20+
1021
## [2.0.2]
1122

1223
## [2.0.1]
@@ -22,7 +33,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2233

2334
- Migrated action from its separate repository to the monorepo
2435

25-
[Unreleased]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.2...HEAD
36+
[Unreleased]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.5...HEAD
37+
[2.0.5]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.2...v2.0.5
2638
[2.0.2]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.1...v2.0.2
2739
[2.0.1]: https://github.com/MetaMask/action-security-code-scanner/compare/v2.0.0...v2.0.1
2840
[2.0.0]: https://github.com/MetaMask/action-security-code-scanner/releases/tag/v2.0.0

packages/semgrep-action/action.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,21 @@ inputs:
1010
runs:
1111
using: 'composite'
1212
steps:
13-
- name: Copy Semgrep Action Files to Workspace Root
14-
run: |
15-
echo "Copying Semgrep action files to workspace root for flat structure..."
16-
cp -r ${{ github.action_path }}/rules ${{ github.workspace }}/
17-
echo "Files copied. Semgrep rules structure:"
18-
ls -la ${{ github.workspace }}/rules/
19-
shell: bash
20-
2113
- name: Install Semgrep
2214
run: |
2315
pip install semgrep
2416
shell: bash
2517

2618
- name: Generate .semgrepignore
2719
run: |
28-
echo "${{ inputs.paths_ignored }}" > .semgrepignore
20+
echo ".security-scanner/" > .semgrepignore
21+
echo "${{ inputs.paths_ignored }}" >> .semgrepignore
2922
cat .semgrepignore
3023
shell: bash
3124

3225
- name: Run Semgrep Scan
3326
run: |
34-
semgrep --config ./rules/src --output semgrep-results.sarif --sarif --verbose
27+
semgrep --config ${{ github.action_path }}/rules/src --output semgrep-results.sarif --sarif --verbose
3528
shell: bash
3629
continue-on-error: true
3730

packages/semgrep-action/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/semgrep-action",
3-
"version": "2.0.2",
3+
"version": "2.0.5",
44
"private": true,
55
"description": "Semgrep-based security scanning action",
66
"keywords": [
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
rules:
2+
- id: npx-usage-js
3+
languages:
4+
- javascript
5+
- typescript
6+
severity: WARNING
7+
metadata:
8+
tags: [security]
9+
shortDescription: 'npx usage introduces supply chain security risks'
10+
confidence: HIGH
11+
help: |
12+
Using npx to install and run packages introduces significant supply chain security risks for the following reasons:
13+
14+
1. **Unpinned by default**: Running `npx <package>` fetches the latest release outside of your lockfile. If a malicious version of a package is published ([example])(https://socket.dev/blog/npm-author-qix-compromised-in-major-supply-chain-attack), `npx` will install and execute it the next time it is run.
15+
16+
2. **Bypasses lockfile guarantees**: Packages executed with npx are not added to your project's package.json or lockfile. As a result, their versions and lockfile integrity hashes are not captured for reproducibility, making builds non-deterministic and harder to audit
17+
18+
### Recommended practice
19+
- Add packages as dependencies or devDependencies in `package.json`.
20+
- Use your package manager to install and execute them (e.g., `yarn add <package> [--dev]` followed by `yarn <package> <command>`).
21+
22+
**Bad example (using npx):**
23+
```javascript
24+
const cmd = `npx jest --coverage`;
25+
execSync(cmd);
26+
```
27+
28+
**Good example (proper dependency):**
29+
```javascript
30+
// Add jest as a dependency /devDependency in package.json
31+
const cmd = `yarn jest --coverage`;
32+
execSync(cmd);
33+
```
34+
35+
message: >-
36+
Avoid using 'npx' to run packages due to supply chain security risks. Instead, install the package
37+
as a dependency / devDependency and invoke it using your package manager to ensure version pinning
38+
and reproducibility.
39+
patterns:
40+
- pattern: '$STRING'
41+
- metavariable-regex:
42+
metavariable: $STRING
43+
regex: '.*\bnpx\s'

0 commit comments

Comments
 (0)