codeql.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. # For most projects, this workflow file will not need changing; you simply need
  2. # to commit it to your repository.
  3. #
  4. # You may wish to alter this file to override the set of languages analyzed,
  5. # or to provide custom queries or build logic.
  6. #
  7. name: "CodeQL"
  8. on:
  9. #pull_request:
  10. # types:
  11. # - opened
  12. # branches: '*'
  13. #push:
  14. # branches: [ "main" ]
  15. # midnight UTC
  16. schedule:
  17. - cron: '0 0 * * *'
  18. # allow to be triggered manually
  19. workflow_dispatch:
  20. jobs:
  21. analyze:
  22. if: github.repository == 'bytecodealliance/wasm-micro-runtime'
  23. name: Analyze
  24. # Runner size impacts CodeQL analysis time. To learn more, please see:
  25. # - https://gh.io/recommended-hardware-resources-for-running-codeql
  26. # - https://gh.io/supported-runners-and-hardware-resources
  27. # - https://gh.io/using-larger-runners
  28. # Consider using larger runners for possible analysis time improvements.
  29. runs-on: ${{ (matrix.language == 'swift' && 'macos-13') || 'ubuntu-20.04' }}
  30. timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
  31. permissions:
  32. actions: read
  33. contents: read
  34. security-events: write
  35. strategy:
  36. fail-fast: false
  37. matrix:
  38. language: [ 'cpp' ]
  39. # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
  40. steps:
  41. - name: Checkout repository
  42. uses: actions/checkout@v3
  43. with:
  44. submodules: recursive
  45. # Initializes the CodeQL tools for scanning.
  46. - name: Initialize CodeQL
  47. uses: github/codeql-action/init@v3
  48. with:
  49. languages: ${{ matrix.language }}
  50. # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
  51. # queries: security-extended,security-and-quality
  52. queries: security-and-quality
  53. # Command-line programs to run using the OS shell.
  54. # See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
  55. # If the Autobuild fails above, remove it and uncomment the following three lines.
  56. # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
  57. - run: |
  58. ./.github/scripts/codeql_buildscript.sh
  59. - name: Perform CodeQL Analysis
  60. uses: github/codeql-action/analyze@v3
  61. with:
  62. category: "/language:${{matrix.language}}"
  63. upload: false
  64. id: step1
  65. # Filter out rules with low severity or high false positve rate
  66. # Also filter out warnings in third-party code
  67. - name: Filter out unwanted errors and warnings
  68. uses: advanced-security/filter-sarif@v1
  69. with:
  70. patterns: |
  71. -**:cpp/path-injection
  72. -**:cpp/world-writable-file-creation
  73. -**:cpp/poorly-documented-function
  74. -**:cpp/potentially-dangerous-function
  75. -**:cpp/use-of-goto
  76. -**:cpp/integer-multiplication-cast-to-long
  77. -**:cpp/comparison-with-wider-type
  78. -**:cpp/leap-year/*
  79. -**:cpp/ambiguously-signed-bit-field
  80. -**:cpp/suspicious-pointer-scaling
  81. -**:cpp/suspicious-pointer-scaling-void
  82. -**:cpp/unsigned-comparison-zero
  83. -**/cmake*/Modules/**
  84. input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
  85. output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
  86. - name: Upload CodeQL results to code scanning
  87. uses: github/codeql-action/upload-sarif@v3
  88. with:
  89. sarif_file: ${{ steps.step1.outputs.sarif-output }}
  90. category: "/language:${{matrix.language}}"
  91. - name: Upload CodeQL results as an artifact
  92. if: success() || failure()
  93. uses: actions/upload-artifact@v4
  94. with:
  95. name: codeql-results
  96. path: ${{ steps.step1.outputs.sarif-output }}
  97. retention-days: 10
  98. - name: Fail if an error is found
  99. run: |
  100. ./.github/scripts/codeql_fail_on_error.py \
  101. ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
  102. env:
  103. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  104. GITHUB_REPOSITORY: ${{ github.repository }}