snyk-security.yml 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # This workflow uses actions that are not certified by GitHub.
  2. # They are provided by a third-party and are governed by
  3. # separate terms of service, privacy policy, and support
  4. # documentation.
  5. # A sample workflow which sets up Snyk to analyze the full Snyk platform (Snyk Open Source, Snyk Code,
  6. # Snyk Container and Snyk Infrastructure as Code)
  7. # The setup installs the Snyk CLI - for more details on the possible commands
  8. # check https://docs.snyk.io/snyk-cli/cli-reference
  9. # The results of Snyk Code are then uploaded to GitHub Security Code Scanning
  10. #
  11. # In order to use the Snyk Action you will need to have a Snyk API token.
  12. # More details in https://github.com/snyk/actions#getting-your-snyk-token
  13. # or you can signup for free at https://snyk.io/login
  14. #
  15. # For more examples, including how to limit scans to only high-severity issues
  16. # and fail PR checks, see https://github.com/snyk/actions/
  17. name: Snyk Security
  18. on:
  19. push:
  20. branches: ["master" ]
  21. pull_request:
  22. branches: ["master"]
  23. permissions:
  24. contents: read
  25. jobs:
  26. snyk:
  27. permissions:
  28. contents: read # for actions/checkout to fetch code
  29. security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
  30. actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
  31. runs-on: ubuntu-latest
  32. steps:
  33. - uses: actions/checkout@v3
  34. - name: Set up Snyk CLI to check for security issues
  35. # Snyk can be used to break the build when it detects security issues.
  36. # In this case we want to upload the SAST issues to GitHub Code Scanning
  37. uses: snyk/actions/setup@806182742461562b67788a64410098c9d9b96adb
  38. # For Snyk Open Source you must first set up the development environment for your application's dependencies
  39. # For example for Node
  40. #- uses: actions/setup-node@v3
  41. # with:
  42. # node-version: 16
  43. env:
  44. # This is where you will need to introduce the Snyk API token created with your Snyk account
  45. SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
  46. # Runs Snyk Code (SAST) analysis and uploads result into GitHub.
  47. # Use || true to not fail the pipeline
  48. - name: Snyk Code test
  49. run: snyk code test --sarif > snyk-code.sarif # || true
  50. # Runs Snyk Open Source (SCA) analysis and uploads result to Snyk.
  51. - name: Snyk Open Source monitor
  52. run: snyk monitor --all-projects
  53. # Runs Snyk Infrastructure as Code (IaC) analysis and uploads result to Snyk.
  54. # Use || true to not fail the pipeline.
  55. - name: Snyk IaC test and report
  56. run: snyk iac test --report # || true
  57. # Build the docker image for testing
  58. - name: Build a Docker image
  59. run: docker build -t your/image-to-test .
  60. # Runs Snyk Container (Container and SCA) analysis and uploads result to Snyk.
  61. - name: Snyk Container monitor
  62. run: snyk container monitor your/image-to-test --file=Dockerfile
  63. # Push the Snyk Code results into GitHub Code Scanning tab
  64. - name: Upload result to GitHub Code Scanning
  65. uses: github/codeql-action/upload-sarif@v2
  66. with:
  67. sarif_file: snyk-code.sarif