Repository navigation
ci: add snyk security check (monitor on main, manual test on branches) #55
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 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
de1453a
ci: add snyk security check (monitor on main, manual test on branches)
odubajDT 6b8b0cd
ci: temporarily run snyk test job on pull_request
odubajDT dcc75ec
ci: scan runtime dependencies only
odubajDT 11c5925
Revert "ci: temporarily run snyk test job on pull_request"
odubajDT 30a48a3
ci: scan example manifests and Dockerfile with snyk
odubajDT c450d36
ci: strip CRLF from the example Dockerfile base image name
odubajDT 95daf78
ci: pin snyk Ruby to 3.4 (fluent-package v6)
odubajDT 91fa854
ci: drop snyk scans of the examples for now
odubajDT 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,107 @@ | ||
| name: Security check | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Check for security vulnerabilities | ||
| # Snyk tracks main only; a manual run on another branch would overwrite main's snapshot. | ||
| if: github.ref == 'refs/heads/main' | ||
| runs-on: ubuntu-26.04 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
|
|
||
| - uses: snyk/actions/setup@9adf32b1121593767fc3c057af55b55db032dc04 # v1.0.0 | ||
|
|
||
| - name: Set up Ruby | ||
| uses: ruby/setup-ruby@f9c4492e86def3e644ab32a0ef185eda5b0c20d0 # v1.342.0 | ||
| with: | ||
| # Ruby bundled with fluent-package v6 LTS; bundle lock resolves for this version. | ||
| ruby-version: '3.4' | ||
|
|
||
| - name: Resolve dependencies | ||
| # No Gemfile.lock is committed (gem convention). Resolve one from the gem's runtime | ||
| # dependencies only, so Snyk scans what ships with the plugin, not dev/test tooling. | ||
| # The gem source is taken over from the repo's own Gemfile. | ||
| run: | | ||
| mkdir snyk-runtime | ||
| grep '^source ' Gemfile > snyk-runtime/Gemfile | ||
| echo "gem 'fluent-plugin-dynatrace', path: '..'" >> snyk-runtime/Gemfile | ||
| (cd snyk-runtime && bundle lock) | ||
|
|
||
| - name: Run Snyk | ||
| env: | ||
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||
| run: snyk monitor --file=snyk-runtime/Gemfile.lock --project-name=dynatrace-oss/fluent-plugin-dynatrace | ||
|
|
||
| - name: Run Snyk on example Kubernetes manifests | ||
| if: ${{ !cancelled() }} | ||
| env: | ||
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||
| # --report uploads the results to Snyk. Exit code 1 only means issues were found, | ||
| # which is expected here: monitoring reports findings but does not fail on them. | ||
| run: snyk iac test example --report --target-name=dynatrace-oss/fluent-plugin-dynatrace || [ "$?" -eq 1 ] | ||
|
|
||
| - name: Run Snyk on example Dockerfile base image | ||
| if: ${{ !cancelled() }} | ||
| env: | ||
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||
| run: | | ||
| base_image=$(awk 'toupper($1) == "FROM" { print $2; exit }' example/Dockerfile | tr -d '\r') | ||
| snyk container monitor "${base_image}" --file=example/Dockerfile \ | ||
|
odubajDT marked this conversation as resolved.
Resolved
|
||
| --project-name=dynatrace-oss/fluent-plugin-dynatrace:example/Dockerfile | ||
|
|
||
| test: | ||
| name: Test for security vulnerabilities (no upload) | ||
| # Manual runs on other branches only report locally via `snyk test`; | ||
| # `snyk monitor` (build job) is reserved for main. | ||
| if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main' | ||
| runs-on: ubuntu-26.04 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
|
|
||
| - uses: snyk/actions/setup@9adf32b1121593767fc3c057af55b55db032dc04 # v1.0.0 | ||
|
|
||
| - name: Set up Ruby | ||
| uses: ruby/setup-ruby@f9c4492e86def3e644ab32a0ef185eda5b0c20d0 # v1.342.0 | ||
| with: | ||
| # Ruby bundled with fluent-package v6 LTS; bundle lock resolves for this version. | ||
| ruby-version: '3.4' | ||
|
|
||
| - name: Resolve dependencies | ||
| # No Gemfile.lock is committed (gem convention). Resolve one from the gem's runtime | ||
| # dependencies only, so Snyk scans what ships with the plugin, not dev/test tooling. | ||
| # The gem source is taken over from the repo's own Gemfile. | ||
| run: | | ||
| mkdir snyk-runtime | ||
| grep '^source ' Gemfile > snyk-runtime/Gemfile | ||
| echo "gem 'fluent-plugin-dynatrace', path: '..'" >> snyk-runtime/Gemfile | ||
| (cd snyk-runtime && bundle lock) | ||
|
|
||
| - name: Run Snyk | ||
| # Findings of all severities (low and above) are reported and fail the job. | ||
| env: | ||
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||
| run: snyk test --severity-threshold=low --file=snyk-runtime/Gemfile.lock | ||
|
|
||
| - name: Run Snyk on example Kubernetes manifests | ||
| if: ${{ !cancelled() }} | ||
| env: | ||
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||
| run: snyk iac test example --severity-threshold=low | ||
|
|
||
| - name: Run Snyk on example Dockerfile base image | ||
| if: ${{ !cancelled() }} | ||
| env: | ||
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | ||
| run: | | ||
| base_image=$(awk 'toupper($1) == "FROM" { print $2; exit }' example/Dockerfile | tr -d '\r') | ||
| snyk container test "${base_image}" --file=example/Dockerfile --severity-threshold=low | ||
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.