-
Notifications
You must be signed in to change notification settings - Fork 49
Add compliance CI checks and scripts #1453
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f937e38
Add SPDX license identifier and update license information across mul…
89f5522
Enhance compliance checks by adding Node.js setup and pnpm support; u…
20b31c1
Refactor compliance workflow: streamline pnpm setup and simplify gitl…
6f4c063
Improve gitleaks installation in compliance workflow with architectur…
fd3b942
Refactor Gitleaks installation in compliance workflow to simplify arc…
14590d7
Enhance gitleaks installation in compliance workflow with dynamic ver…
ce61a23
Merge branch 'main' into chralt98-add-compliance-checks
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| rules: | ||
| - id: rust-no-dbg-in-runtime | ||
| message: Avoid dbg! in runtimes and pallets; use logging macros instead. | ||
| severity: WARNING | ||
| languages: [rust] | ||
| pattern: dbg!($X) | ||
| paths: | ||
| include: | ||
| - /runtime/** | ||
| - /zrml/** | ||
|
|
||
| - id: rust-no-println-in-runtime | ||
| message: Avoid println! in runtimes and pallets; use logging macros instead. | ||
| severity: WARNING | ||
| languages: [rust] | ||
| pattern: println!($X) | ||
| paths: | ||
| include: | ||
| - /runtime/** | ||
| - /zrml/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| name: Compliance | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [ labeled ] | ||
| push: | ||
| branches: [ main ] | ||
|
|
||
| concurrency: | ||
| group: compliance-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| cargo-deny: | ||
| name: Cargo Deny | ||
| if: | | ||
| github.event_name == 'pull_request' && | ||
| (contains(github.event.pull_request.labels.*.name, 's:review-needed') || | ||
| contains(github.event.pull_request.labels.*.name, 's:accepted')) || | ||
| github.event_name == 'push' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Install cargo-deny | ||
| uses: taiki-e/install-action@v2 | ||
| with: | ||
| tool: cargo-deny | ||
| - name: Run cargo-deny | ||
| run: | | ||
| cargo deny check licenses bans sources advisories | ||
|
|
||
| semgrep: | ||
| name: Semgrep | ||
| if: | | ||
| github.event_name == 'pull_request' && | ||
| (contains(github.event.pull_request.labels.*.name, 's:review-needed') || | ||
| contains(github.event.pull_request.labels.*.name, 's:accepted')) || | ||
| github.event_name == 'push' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Run semgrep | ||
| uses: returntocorp/semgrep-action@v1 | ||
| with: | ||
| config: .github/semgrep-rules.yml | ||
|
|
||
| node-licenses: | ||
| name: Node Licenses | ||
| if: | | ||
| github.event_name == 'pull_request' && | ||
| (contains(github.event.pull_request.labels.*.name, 's:review-needed') || | ||
| contains(github.event.pull_request.labels.*.name, 's:accepted')) || | ||
| github.event_name == 'push' | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: integration-tests | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| run_install: false | ||
| version: 9 | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: 'pnpm' | ||
| cache-dependency-path: integration-tests/pnpm-lock.yaml | ||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
| - name: Check licenses | ||
| run: pnpm dlx license-checker --production --summary | ||
| - name: Audit npm | ||
| run: pnpm audit --prod | ||
|
|
||
| gitleaks: | ||
| name: Gitleaks | ||
| if: | | ||
| ( | ||
| github.event_name == 'pull_request' && | ||
| (contains(github.event.pull_request.labels.*.name, 's:review-needed') || | ||
| contains(github.event.pull_request.labels.*.name, 's:accepted')) | ||
| ) || | ||
| github.event_name == 'push' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Install gitleaks (OSS) | ||
| run: | | ||
| set -euo pipefail | ||
| version="$( | ||
| curl -sI https://github.com/gitleaks/gitleaks/releases/latest \ | ||
| | tr -d '\r' \ | ||
| | awk 'tolower($1) == "location:" {print $2}' \ | ||
| | sed -E 's#.*/tag/v?##; s#^v##' | ||
| )" | ||
|
|
||
| if [[ -z "${version}" || "${version}" == "null" ]]; then | ||
| echo "Failed to determine gitleaks version" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| arch="$(uname -m)" | ||
| os="$(uname -s | tr '[:upper:]' '[:lower:]')" | ||
|
|
||
| case "${arch}" in | ||
| x86_64) arch="x64" ;; | ||
| aarch64 | arm64) arch="arm64" ;; | ||
| *) | ||
| echo "Unsupported architecture: ${arch}" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| curl -sSfL "https://github.com/gitleaks/gitleaks/releases/download/v${version}/gitleaks_${version}_${os}_${arch}.tar.gz" \ | ||
| | tar -xz -C /tmp gitleaks | ||
| chmod +x /tmp/gitleaks | ||
| /tmp/gitleaks version | ||
| - name: Run gitleaks | ||
| run: /tmp/gitleaks detect --redact | ||
|
|
||
| sbom-vuln: | ||
| name: SBOM and Vulnerability Scan | ||
| if: | | ||
| github.event_name == 'pull_request' && | ||
| (contains(github.event.pull_request.labels.*.name, 's:review-needed') || | ||
| contains(github.event.pull_request.labels.*.name, 's:accepted')) || | ||
| github.event_name == 'push' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Generate SBOM | ||
| uses: anchore/sbom-action@v0 | ||
| with: | ||
| path: . | ||
| output-file: sbom.json | ||
| format: cyclonedx-json | ||
| syft-version: latest | ||
| - name: Scan SBOM | ||
| uses: anchore/scan-action@v3 | ||
| env: | ||
| GRYPE_CONFIG: ${{ github.workspace }}/.grype.yaml | ||
| with: | ||
| sbom: sbom.json | ||
| grype-version: latest | ||
| fail-build: false | ||
| severity-cutoff: medium | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: Scancode | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| tags: | ||
| - "^v[0-9]+.[0-9]+.[0-9]+(-rc[0-9]+)?$" | ||
|
Chralt98 marked this conversation as resolved.
|
||
|
|
||
| jobs: | ||
| scancode: | ||
| name: Scancode | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Install scancode | ||
| run: pip install scancode-toolkit | ||
| - name: Run scancode | ||
| run: scancode --processes 4 -clp . --json-pp compliance-report.json | ||
| - name: Upload scancode report | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: scancode-report | ||
| path: compliance-report.json | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| description = "Allow known public addresses and test keys that gitleaks flags" | ||
| title = "Zeitgeist gitleaks allowlist" | ||
|
|
||
| [allowlist] | ||
| paths = [ | ||
| '''^integration-tests/scripts/chopsticks-relay-timestamp-hook\.js$''', | ||
| '''^integration-tests/configs/rococo\.yml$''', | ||
| '''^integration-tests/configs/battery-station\.yml$''', | ||
| '''^runtime/battery-station/src/parachain_params\.rs$''', | ||
| '''^runtime/zeitgeist/src/parachain_params\.rs$''', | ||
| '''^scripts/runtime-upgrade/test_runtime_upgrade\.sh$''', | ||
| '''^node/res/bs_parachain\.json$''', | ||
| '''^node/res/bp\.json$''', | ||
| '''^node/res/bp_parachain\.json$''', | ||
| ] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.