codeql.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. # ******** NOTE ********
  8. # We have attempted to detect the languages in your repository. Please check
  9. # the `language` matrix defined below to confirm you have the correct set of
  10. # supported CodeQL languages.
  11. #
  12. name: "CodeQL"
  13. on:
  14. push:
  15. branches: [ "master" ]
  16. paths-ignore:
  17. - src/third_party/**
  18. schedule:
  19. - cron: '0 0 * * *'
  20. pull_request:
  21. branches: '*'
  22. paths-ignore:
  23. - src/third_party/**
  24. jobs:
  25. analyze:
  26. name: Analyze
  27. # Runner size impacts CodeQL analysis time. To learn more, please see:
  28. # - https://gh.io/recommended-hardware-resources-for-running-codeql
  29. # - https://gh.io/supported-runners-and-hardware-resources
  30. # - https://gh.io/using-larger-runners
  31. # Consider using larger runners for possible analysis time improvements.
  32. runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
  33. timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
  34. permissions:
  35. actions: read
  36. contents: read
  37. security-events: write
  38. strategy:
  39. fail-fast: false
  40. matrix:
  41. language: [ 'cpp' ]
  42. # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
  43. # Use only 'java' to analyze code written in Java, Kotlin or both
  44. # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
  45. # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
  46. steps:
  47. - name: Checkout repository
  48. uses: actions/checkout@v5
  49. with:
  50. submodules: recursive
  51. # Initializes the CodeQL tools for scanning.
  52. - name: Initialize CodeQL
  53. uses: github/codeql-action/init@v4
  54. with:
  55. languages: ${{ matrix.language }}
  56. # If you wish to specify custom queries, you can do so here or in a config file.
  57. # By default, queries listed here will override any specified in a config file.
  58. # Prefix the list here with "+" to use these queries and those in the config file.
  59. # 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
  60. # queries: security-extended,security-and-quality
  61. queries: security-and-quality
  62. # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
  63. # If this step fails, then you should remove it and run the build manually (see below)
  64. #- name: Autobuild
  65. # uses: github/codeql-action/autobuild@v2
  66. # ℹ️ Command-line programs to run using the OS shell.
  67. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
  68. # If the Autobuild fails above, remove it and uncomment the following three lines.
  69. # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
  70. - run: |
  71. make build WITH_ALL=1
  72. - name: Perform CodeQL Analysis
  73. uses: github/codeql-action/analyze@v4
  74. with:
  75. category: "/language:${{matrix.language}}"
  76. upload: false
  77. id: step1
  78. # Filter out rules with low severity or high false positve rate
  79. # Also filter out warnings in third-party code
  80. - name: Filter out unwanted errors and warnings
  81. uses: advanced-security/filter-sarif@v1
  82. with:
  83. patterns: |
  84. -**:cpp/path-injection
  85. -**:cpp/world-writable-file-creation
  86. -**:cpp/poorly-documented-function
  87. -**:cpp/potentially-dangerous-function
  88. -**:cpp/use-of-goto
  89. -**:cpp/integer-multiplication-cast-to-long
  90. -**:cpp/comparison-with-wider-type
  91. -**:cpp/leap-year/*
  92. -**:cpp/ambiguously-signed-bit-field
  93. -**:cpp/suspicious-pointer-scaling
  94. -**:cpp/suspicious-pointer-scaling-void
  95. -**:cpp/unsigned-comparison-zero
  96. -**/cmake*/Modules/**
  97. input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
  98. output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
  99. - name: Upload CodeQL results to code scanning
  100. uses: github/codeql-action/upload-sarif@v4
  101. with:
  102. sarif_file: ${{ steps.step1.outputs.sarif-output }}
  103. category: "/language:${{matrix.language}}"
  104. - name: Upload CodeQL results as an artifact
  105. if: success() || failure()
  106. uses: actions/upload-artifact@v4
  107. with:
  108. name: codeql-results
  109. path: ${{ steps.step1.outputs.sarif-output }}
  110. retention-days: 5
  111. - name: Fail if an error is found
  112. run: |
  113. ./.github/workflows/fail_on_error.py \
  114. ${{ steps.step1.outputs.sarif-output }}/cpp.sarif