Skip to content

Commit 7e366ee

Browse files
added security best practises (#212)
* added security best practises * Vulnerability fixes * updating .md files with npm ci * Handle package files conditions. * Handle package files conditions. --------- Co-authored-by: Aniket Shinde <aniket.shinde@checkmarx.com>
1 parent d6332e9 commit 7e366ee

7 files changed

Lines changed: 58 additions & 101 deletions

File tree

.github/workflows/ci.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,45 @@ jobs:
99
runs-on: cx-public-ubuntu-x64
1010
steps:
1111
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
12+
- name: Verify single lockfile (Step 0 - Supply Chain Policy)
13+
run: |
14+
if [ -f yarn.lock ] && [ -f package-lock.json ]; then
15+
echo "❌ ERROR: Both yarn.lock and package-lock.json found. Policy requires exactly ONE package manager. Allowed: npm + package-lock.json OR Yarn + yarn.lock"
16+
exit 1
17+
fi
18+
if [ ! -f yarn.lock ] && [ ! -f package-lock.json ]; then
19+
echo "❌ ERROR: No lockfile found. Policy requires exactly ONE package manager lockfile. Required: npm + package-lock.json OR Yarn + yarn.lock"
20+
exit 1
21+
fi
1222
- name: Use Node.js 22.11.0
1323
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
1424
with:
1525
node-version: 22.11.0
1626
registry-url: https://npm.pkg.github.com/
17-
- run: npm ci
27+
- run: npm ci --ignore-scripts
1828
- name: Run Unit Tests
1929

2030
run: npm run test:unit
2131
integration-tests:
2232
runs-on: cx-public-ubuntu-x64
2333
steps:
2434
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
35+
- name: Verify single lockfile (Step 0 - Supply Chain Policy)
36+
run: |
37+
if [ -f yarn.lock ] && [ -f package-lock.json ]; then
38+
echo "❌ ERROR: Both yarn.lock and package-lock.json found. Policy requires exactly ONE package manager. Allowed: npm + package-lock.json OR Yarn + yarn.lock"
39+
exit 1
40+
fi
41+
if [ ! -f yarn.lock ] && [ ! -f package-lock.json ]; then
42+
echo "❌ ERROR: No lockfile found. Policy requires exactly ONE package manager lockfile. Required: npm + package-lock.json OR Yarn + yarn.lock"
43+
exit 1
44+
fi
2545
- name: Use Node.js 22.11.0
2646
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
2747
with:
2848
node-version: 22.11.0
2949
registry-url: https://npm.pkg.github.com/
30-
- run: npm ci
50+
- run: npm ci --ignore-scripts
3151
- name: Code Linting
3252
run: npm run lint
3353
- run: npm run build --if-present

.github/workflows/release.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,17 @@ jobs:
7474
with:
7575
fetch-depth: 0
7676

77-
- name: Git Configuration
77+
- name: Verify single lockfile (Step 0 - Supply Chain Policy)
78+
run: |
79+
if [ -f yarn.lock ] && [ -f package-lock.json ]; then
80+
echo "❌ ERROR: Both yarn.lock and package-lock.json found. Policy requires exactly ONE package manager. Allowed: npm + package-lock.json OR Yarn + yarn.lock"
81+
exit 1
82+
fi
83+
if [ ! -f yarn.lock ] && [ ! -f package-lock.json ]; then
84+
echo "❌ ERROR: No lockfile found. Policy requires exactly ONE package manager lockfile. Required: npm + package-lock.json OR Yarn + yarn.lock"
85+
exit 1
86+
fi
87+
- name: Git Configuration
7888
run: |
7989
git config user.name github-actions
8090
git config user.email github-actions@github.com
@@ -137,7 +147,7 @@ jobs:
137147
138148
- name: NPM ci and build
139149
run: |
140-
npm ci
150+
npm ci --ignore-scripts
141151
npm run build
142152
143153
- name: Create Pull Request

.npmrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Default registry for most packages
2-
registry=https://npm.echohq.com/
2+
registry=https://npm.echohq.com/
3+
ignore-scripts=true

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ CxWrapper (Main Entry Point)
188188

189189
2. **Install dependencies**
190190
```bash
191-
npm install
191+
npm ci
192192
```
193193

194194
3. **Verify installation**

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ To be able to build the code you should have:
5353
### Setting Up
5454

5555
In your terminal, run:
56-
```
57-
- npm install
56+
```bash
57+
npm ci
5858
```
5959

6060
To run integrations tests, you need to set up environment variables:

package-lock.json

Lines changed: 18 additions & 93 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"overrides": {
5959
"bluebird": "3.7.2",
6060
"flatted": "^3.4.2",
61+
"js-yaml": "4.2.0",
6162
"lodash": "^4.18.0",
6263
"minimatch": "^3.1.2",
6364
"underscore": "^1.13.8",

0 commit comments

Comments
 (0)