|  | 
|  | 1 | +name: "CodeQL config" | 
|  | 2 | + | 
|  | 3 | +queries: | 
|  | 4 | +  - uses: security-extended | 
|  | 5 | + | 
|  | 6 | +paths-ignore: | 
|  | 7 | +  - gitweb/**/*.js # GitWeb is not distributed | 
|  | 8 | + | 
|  | 9 | +query-filters: | 
|  | 10 | +  - exclude: | 
|  | 11 | +    # yes, this extra indentation is intentional | 
|  | 12 | +      # too common in Git's source code | 
|  | 13 | +      id: cpp/trivial-switch | 
|  | 14 | +  - exclude: | 
|  | 15 | +      id: cpp/loop-variable-changed | 
|  | 16 | +  - exclude: | 
|  | 17 | +      # we override this locally with a modified version | 
|  | 18 | +      id: cpp/non-constant-format | 
|  | 19 | +  - exclude: | 
|  | 20 | +      # Git does not consider this a problem | 
|  | 21 | +      id: cpp/irregular-enum-init | 
|  | 22 | +  - exclude: | 
|  | 23 | +      # Git has many long functions, this alert would match too many | 
|  | 24 | +      id: cpp/poorly-documented-function | 
|  | 25 | +  - exclude: | 
|  | 26 | +      # In Git, there is a lot of commented-out code | 
|  | 27 | +      id: cpp/commented-out-code | 
|  | 28 | +  - exclude: | 
|  | 29 | +      # While it is true that long switch cases are hard to read and | 
|  | 30 | +      # validate, Git has way too many for us to allow this query to | 
|  | 31 | +      # churn out alerts left and right | 
|  | 32 | +      id: cpp/long-switch | 
|  | 33 | +  - exclude: | 
|  | 34 | +      # CodeQL does not expect Git to heed the umask(), but it does | 
|  | 35 | +      id: cpp/world-writable-file-creation | 
|  | 36 | +  - exclude: | 
|  | 37 | +      # Git uses the construct `if (<not this>) ; else ...` often, to | 
|  | 38 | +      # avoid an extra indentation level. CodeQL does not like that. | 
|  | 39 | +      id: cpp/empty-block | 
|  | 40 | +  - exclude: | 
|  | 41 | +      # This rule unfortunately triggers some false positives, e.g. | 
|  | 42 | +      # where Git tries to redact URLs or where Git specifically | 
|  | 43 | +      # asks for a password upon GIT_SSL_CERT_PASSWORD_PROTECTED. | 
|  | 44 | +      id: cpp/user-controlled-bypass | 
|  | 45 | +  - exclude: | 
|  | 46 | +      # This rule fails to recognize that xmallocz() _specifically_ | 
|  | 47 | +      # makes room for a trailing NUL, and instead assumes that this | 
|  | 48 | +      # function behaves like malloc(), which does not. | 
|  | 49 | +      id: cpp/invalid-pointer-deref | 
|  | 50 | +  - exclude: | 
|  | 51 | +      # CodeQL fails to recognize that xmallocz() accounts for the NUL, | 
|  | 52 | +      # instead assuming malloc() semantics. | 
|  | 53 | +      id: cpp/no-space-for-terminator | 
|  | 54 | +  - exclude: | 
|  | 55 | +      # Git does exchange plain-text passwords via stdin/stdout e.g. | 
|  | 56 | +      # with helpers in the credential protocol, or in credential-cache. | 
|  | 57 | +      # This rule, though, assumes that writing to _any_ file descriptor | 
|  | 58 | +      # is unsafe. | 
|  | 59 | +      id: cpp/cleartext-storage-file | 
|  | 60 | +  - exclude: | 
|  | 61 | +      # When storing the value of the environment variable `PWD` as the | 
|  | 62 | +      # current directory in absolute_pathdup(), or when allocating memory | 
|  | 63 | +      # for a binary patch where the size is specified in the patch itself, | 
|  | 64 | +      # CodeQL assumes that this can lead to a denial of service because | 
|  | 65 | +      # of an unbounded size, but Git's code works as designed here. | 
|  | 66 | +      id: cpp/uncontrolled-allocation-size | 
|  | 67 | +  - exclude: | 
|  | 68 | +      # lock_repo_for_gc() has admittedly obtuse logic to parse the | 
|  | 69 | +      # process ID out of the `gc.pid` file, which is correct, but | 
|  | 70 | +      # due to its construction throws a false positive here. | 
|  | 71 | +      id: cpp/missing-check-scanf | 
|  | 72 | +  - exclude: | 
|  | 73 | +      # discard_cache_entry() overwrites the name in a FLEX_ARRAY struct | 
|  | 74 | +      # if GIT_TEST_VALIDATE_INDEX_CACHE_ENTRIES is set, which CodeQL fails | 
|  | 75 | +      # to recognize as valid. | 
|  | 76 | +      id: cpp/overrun-write | 
|  | 77 | +  - exclude: | 
|  | 78 | +      # Since `time_t` can be signed or unsigned, there is unfortunately | 
|  | 79 | +      # no way to avoid letting this rule report a potential | 
|  | 80 | +      id: cpp/integer-multiplication-cast-to-long | 
|  | 81 | +  - exclude: | 
|  | 82 | +      # There are many, many legitimate code paths in Git where a path is | 
|  | 83 | +      # constructed from an environment variable, e.g. GIT_DIR. Let's suppress | 
|  | 84 | +      # this slightly overzealous query. | 
|  | 85 | +      id: cpp/path-injection | 
|  | 86 | +  - exclude: | 
|  | 87 | +      # Git has 99 instances of this at the time of writing :-( | 
|  | 88 | +      id: cpp/declaration-hides-variable | 
|  | 89 | +  - exclude: | 
|  | 90 | +      id: cpp/declaration-hides-parameter | 
|  | 91 | +  - exclude: | 
|  | 92 | +      id: cpp/local-variable-hides-global-variable | 
|  | 93 | +  - exclude: | 
|  | 94 | +      id: cpp/complex-condition | 
|  | 95 | +  - exclude: | 
|  | 96 | +      # Nested, long-winded switch statements are hard to read and hard | 
|  | 97 | +      # to reason about. Looking at you, `format_commit_one()`. | 
|  | 98 | +      id: cpp/complex-block | 
|  | 99 | +  - exclude: | 
|  | 100 | +      # There are four instances of this at time of writing, all intentional. | 
|  | 101 | +      # However, it is very easy to introduce unintentional re-use of loop | 
|  | 102 | +      # variable names, therefore we will most likely want to either change these | 
|  | 103 | +      # instances or add suppressions. | 
|  | 104 | +      id: cpp/nested-loops-with-same-variable | 
|  | 105 | +  - exclude: | 
|  | 106 | +      # zOMG so many FIXMEs | 
|  | 107 | +      id: cpp/fixme-comment | 
|  | 108 | +  - exclude: | 
|  | 109 | +      # Git assumes quite a bit about the user's control of the current worktree | 
|  | 110 | +      # Therefore, it kind of assumes that TOCTOU issues are not a thing when | 
|  | 111 | +      # it comes to files. | 
|  | 112 | +      id: cpp/toctou-race-condition | 
|  | 113 | +  - exclude: | 
|  | 114 | +      # Too many results in Git where the code was, however, intentionally written | 
|  | 115 | +      # the way it is. | 
|  | 116 | +      id: cpp/stack-address-escape | 
|  | 117 | +  - exclude: | 
|  | 118 | +      id: cpp/inconsistent-null-check | 
|  | 119 | +  - exclude: | 
|  | 120 | +      # This would trigger alerts in the functions in `help.c` that want to open | 
|  | 121 | +      # external programs to show manual pages. | 
|  | 122 | +      id: cpp/uncontrolled-process-operation | 
|  | 123 | +  - exclude: | 
|  | 124 | +      # The code in t/unit-tests/u-ctype.c implicitly exercises the `sane_istest()` | 
|  | 125 | +      # macro extensively, and CodeQL seems to miss the cast to `(unsigned char)`, | 
|  | 126 | +      # thereby mistaking the accesses for being past the end of the array (which | 
|  | 127 | +      # is incorrect). | 
|  | 128 | +      # | 
|  | 129 | +      # Ideally, we would exclude test programs from CodeQL anyways, but | 
|  | 130 | +      # unfortunately there is no Makefile rule in Git's code base to build only | 
|  | 131 | +      # the production code, and CodeQL's `paths-ignore` directive described at | 
|  | 132 | +      # https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#specifying-directories-to-scan | 
|  | 133 | +      # unfortunately is _ignored_ for compiled languages. | 
|  | 134 | +      id: cpp/overflow-buffer | 
0 commit comments