codeql.yml 4.2 KB

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