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

update use-frozen-lockfile rule #3040

Merged
merged 3 commits into from
Aug 14, 2023
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
5 changes: 1 addition & 4 deletions .github/workflows/semgrep-rules-test-historical.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ jobs:
- name: grab historical semgrep version
env:
GH_TOKEN: ${{ github.token }}
run: |
SEMGREP_OLD_VERSION=$(gh api --method GET /repos/returntocorp/semgrep/releases | jq -r '.[].tag_name' | sed -n 10p | tr -d v)
echo $SEMGREP_OLD_VERSION
echo "SEMGREP_OLD_VERSION=$SEMGREP_OLD_VERSION" >> $GITHUB_ENV
run: semgrep-rules/scripts/historical-semgrep-version
- name: validate rules on historical semgrep version
run: |
docker run --rm -v ${GITHUB_WORKSPACE}/semgrep-rules:/src returntocorp/semgrep:${SEMGREP_OLD_VERSION} semgrep --validate --config /src
Expand Down
3 changes: 3 additions & 0 deletions generic/ci/security/use-frozen-lockfile.fixed.generic
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ RUN yarn install --prod --frozen-lockfile --prefer-offline --ignore-optional --n
# ok: use-frozen-lockfile-yarn
RUN yarn install --production --frozen-lockfile

# ok: use-frozen-lockfile-npm
# i am a comment, just to explain.. npm install

RUN yarn install --frozen-lockfile
RUN yarn install --immutable
# ruleid: use-frozen-lockfile-yarn
Expand Down
3 changes: 3 additions & 0 deletions generic/ci/security/use-frozen-lockfile.generic
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ RUN yarn install --prod --frozen-lockfile --prefer-offline --ignore-optional --n
# ok: use-frozen-lockfile-yarn
RUN yarn install --production --frozen-lockfile

# ok: use-frozen-lockfile-npm
# i am a comment, just to explain.. npm install

RUN yarn install --frozen-lockfile
RUN yarn install --immutable
# ruleid: use-frozen-lockfile-yarn
Expand Down
1 change: 1 addition & 0 deletions generic/ci/security/use-frozen-lockfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ rules:
- pattern-not-regex: npm install -g
- pattern-not-regex: npm install --global
- pattern-not-regex: npm install [\w]+
- pattern-not-regex: \#(.*)
fix: npm ci
message: >-
To ensure reproducible and deterministic builds, use `npm ci` rather than `npm install` in scripts.
Expand Down
17 changes: 17 additions & 0 deletions scripts/historical-semgrep-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
HISTORICAL_VERSIONS=10
RETRIES=3

versions=$(gh api --method GET /repos/returntocorp/semgrep/releases | jq 'reverse' | jq -r '.[].tag_name' | tail "-n${HISTORICAL_VERSIONS}" | head -n "${RETRIES}" | tr -d v)

for version in $(echo "${versions}"); do
docker pull "returntocorp/semgrep:${version}"
if [[ "$?" == 0 ]]; then
echo "${version}"
echo "SEMGREP_OLD_VERSION=${version}" >> "${GITHUB_ENV}"
exit 0
fi
done

echo "Could not determine historical version, tried: $(echo ${versions})"
exit 1
Loading