Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1836723

Browse files
Merge branch 'main' into ZipSlip
2 parents 3c9de6f + 3b4206c commit 1836723

1,225 files changed

Lines changed: 44203 additions & 12528 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/check-qldoc.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "Check QLdoc coverage"
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "*/ql/lib/**"
7+
- .github/workflows/check-qldoc.yml
8+
branches:
9+
- main
10+
- "rc/*"
11+
12+
jobs:
13+
qldoc:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Install CodeQL
18+
run: |
19+
gh extension install github/gh-codeql
20+
gh codeql set-channel nightly
21+
gh codeql version
22+
env:
23+
GITHUB_TOKEN: ${{ github.token }}
24+
25+
- uses: actions/checkout@v2
26+
with:
27+
fetch-depth: 2
28+
29+
- name: Check QLdoc coverage
30+
shell: bash
31+
run: |
32+
EXIT_CODE=0
33+
changed_lib_packs="$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | { grep -o '^[a-z]*/ql/lib' || true; } | sort -u)"
34+
for pack_dir in ${changed_lib_packs}; do
35+
lang="${pack_dir%/ql/lib}"
36+
gh codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-current.txt" --dir="${pack_dir}"
37+
done
38+
git checkout HEAD^
39+
for pack_dir in ${changed_lib_packs}; do
40+
lang="${pack_dir%/ql/lib}"
41+
gh codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-baseline.txt" --dir="${pack_dir}"
42+
awk -F, '{gsub(/"/,""); if ($4==0 && $6=="public") print "\""$3"\"" }' "${RUNNER_TEMP}/${lang}-current.txt" | sort -u > "${RUNNER_TEMP}/current-undocumented.txt"
43+
awk -F, '{gsub(/"/,""); if ($4==0 && $6=="public") print "\""$3"\"" }' "${RUNNER_TEMP}/${lang}-baseline.txt" | sort -u > "${RUNNER_TEMP}/baseline-undocumented.txt"
44+
UNDOCUMENTED="$(grep -f <(comm -13 "${RUNNER_TEMP}/baseline-undocumented.txt" "${RUNNER_TEMP}/current-undocumented.txt") "${RUNNER_TEMP}/${lang}-current.txt" || true)"
45+
if [ -n "$UNDOCUMENTED" ]; then
46+
echo "$UNDOCUMENTED" | awk -F, '{gsub(/"/,""); print "::warning file='"${pack_dir}"'/"$1",line="$2"::Missing QLdoc for "$5, $3 }'
47+
EXIT_CODE=1
48+
fi
49+
done
50+
exit "${EXIT_CODE}"

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ If you have an idea for a query that you would like to share with other CodeQL u
3636

3737
For details, see the [guide on query metadata](docs/query-metadata-style-guide.md).
3838

39-
Make sure the `select` statement is compatible with the query `@kind`. See [About CodeQL queries](https://help.semmle.com/QL/learn-ql/writing-queries/introduction-to-queries.html#select-clause) on help.semmle.com.
39+
Make sure the `select` statement is compatible with the query `@kind`. See [About CodeQL queries](https://codeql.github.com/docs/writing-codeql-queries/about-codeql-queries/#select-clause) on codeql.github.com.
4040

4141
3. **Formatting**
4242

config/blame-deprecations.mjs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import fs from "fs";
2+
import path from "path";
3+
import cp from "child_process";
4+
function* walk(dir) {
5+
for (const file of fs.readdirSync(dir)) {
6+
const filePath = path.join(dir, file);
7+
if (fs.statSync(filePath).isDirectory()) {
8+
yield* walk(filePath);
9+
} else {
10+
yield filePath;
11+
}
12+
}
13+
}
14+
15+
function* deprecatedFiles(dir) {
16+
for (const file of walk(dir)) {
17+
if (file.endsWith(".ql") || file.endsWith(".qll")) {
18+
const contents = fs.readFileSync(file, "utf8");
19+
if (/\sdeprecated\s/.test(contents)) {
20+
yield file;
21+
}
22+
}
23+
}
24+
}
25+
26+
const blameRegExp =
27+
/^(\^?\w+)\s.+\s+(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} (?:\+|-)\d{4})\s+(\d+)\).*$/;
28+
29+
function* deprecationMessages(dir) {
30+
for (const file of deprecatedFiles(dir)) {
31+
const blame = cp.execFileSync("git", ["blame", "--", file]);
32+
const lines = blame.toString().split("\n");
33+
for (let i = 0; i < lines.length; i++) {
34+
const line = lines[i];
35+
if (line.includes(" deprecated ")) {
36+
try {
37+
const [_, sha, time, lineNumber] = line.match(blameRegExp);
38+
const date = new Date(time);
39+
// check if it's within the last 14 months (a year, plus 2 months for safety, in case a PR was delayed)
40+
if (date.getTime() >= Date.now() - 14 * 31 * 24 * 60 * 60 * 1000) {
41+
continue;
42+
}
43+
const message = `${file}:${lineNumber} was last updated on ${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`;
44+
yield [message, date];
45+
} catch (e) {
46+
console.log(e);
47+
console.log("----");
48+
console.log(line);
49+
console.log("----");
50+
process.exit(0);
51+
}
52+
}
53+
}
54+
}
55+
}
56+
[...deprecationMessages(".")]
57+
.sort((a, b) => a[1].getTime() - b[1].getTime())
58+
.forEach((msg) => console.log(msg[0]));

config/identical-files.json

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl3.qll",
2828
"python/ql/lib/semmle/python/dataflow/new/internal/DataFlowImpl4.qll",
2929
"ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImpl.qll",
30-
"ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImpl2.qll"
30+
"ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImpl2.qll",
31+
"ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImplForLibraries.qll"
3132
],
3233
"DataFlow Java/C++/C#/Python Common": [
3334
"java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImplCommon.qll",
@@ -54,7 +55,8 @@
5455
"python/ql/lib/semmle/python/dataflow/new/internal/tainttracking2/TaintTrackingImpl.qll",
5556
"python/ql/lib/semmle/python/dataflow/new/internal/tainttracking3/TaintTrackingImpl.qll",
5657
"python/ql/lib/semmle/python/dataflow/new/internal/tainttracking4/TaintTrackingImpl.qll",
57-
"ruby/ql/lib/codeql/ruby/dataflow/internal/tainttracking1/TaintTrackingImpl.qll"
58+
"ruby/ql/lib/codeql/ruby/dataflow/internal/tainttracking1/TaintTrackingImpl.qll",
59+
"ruby/ql/lib/codeql/ruby/dataflow/internal/tainttrackingforlibraries/TaintTrackingImpl.qll"
5860
],
5961
"DataFlow Java/C++/C#/Python Consistency checks": [
6062
"java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImplConsistency.qll",
@@ -73,6 +75,14 @@
7375
"java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/SsaReadPositionCommon.qll",
7476
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SsaReadPositionCommon.qll"
7577
],
78+
"Model as Data Generation Java/C# - Utils": [
79+
"java/ql/src/utils/model-generator/ModelGeneratorUtils.qll",
80+
"csharp/ql/src/utils/model-generator/ModelGeneratorUtils.qll"
81+
],
82+
"Model as Data Generation Java/C# - SummaryModels": [
83+
"java/ql/src/utils/model-generator/CaptureSummaryModels.qll",
84+
"csharp/ql/src/utils/model-generator/CaptureSummaryModels.qll"
85+
],
7686
"Sign Java/C#": [
7787
"java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/Sign.qll",
7888
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/Sign.qll"
@@ -472,11 +482,12 @@
472482
"python/ql/lib/semmle/python/security/performance/ReDoSUtil.qll",
473483
"ruby/ql/lib/codeql/ruby/security/performance/ReDoSUtil.qll"
474484
],
475-
"ReDoS Exponential Python/JS": [
485+
"ReDoS Exponential Python/JS/Ruby": [
476486
"javascript/ql/lib/semmle/javascript/security/performance/ExponentialBackTracking.qll",
477-
"python/ql/lib/semmle/python/security/performance/ExponentialBackTracking.qll"
487+
"python/ql/lib/semmle/python/security/performance/ExponentialBackTracking.qll",
488+
"ruby/ql/lib/codeql/ruby/security/performance/ExponentialBackTracking.qll"
478489
],
479-
"ReDoS Polynomial Python/JS": [
490+
"ReDoS Polynomial Python/JS/Ruby": [
480491
"javascript/ql/lib/semmle/javascript/security/performance/SuperlinearBackTracking.qll",
481492
"python/ql/lib/semmle/python/security/performance/SuperlinearBackTracking.qll",
482493
"ruby/ql/lib/codeql/ruby/security/performance/SuperlinearBackTracking.qll"
@@ -507,5 +518,35 @@
507518
"java/ql/lib/semmle/code/java/dataflow/internal/AccessPathSyntax.qll",
508519
"javascript/ql/lib/semmle/javascript/frameworks/data/internal/AccessPathSyntax.qll",
509520
"ruby/ql/lib/codeql/ruby/dataflow/internal/AccessPathSyntax.qll"
521+
],
522+
"Concepts Python/Ruby/JS": [
523+
"python/ql/lib/semmle/python/internal/ConceptsShared.qll",
524+
"ruby/ql/lib/codeql/ruby/internal/ConceptsShared.qll",
525+
"javascript/ql/lib/semmle/javascript/internal/ConceptsShared.qll"
526+
],
527+
"Hostname Regexp queries": [
528+
"javascript/ql/src/Security/CWE-020/HostnameRegexpShared.qll",
529+
"python/ql/src/Security/CWE-020/HostnameRegexpShared.qll",
530+
"ruby/ql/src/queries/security/cwe-020/HostnameRegexpShared.qll"
531+
],
532+
"ApiGraphModels": [
533+
"javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModels.qll",
534+
"ruby/ql/lib/codeql/ruby/frameworks/data/internal/ApiGraphModels.qll"
535+
],
536+
"TaintedFormatStringQuery Ruby/JS": [
537+
"javascript/ql/lib/semmle/javascript/security/dataflow/TaintedFormatStringQuery.qll",
538+
"ruby/ql/lib/codeql/ruby/security/TaintedFormatStringQuery.qll"
539+
],
540+
"TaintedFormatStringCustomizations Ruby/JS": [
541+
"javascript/ql/lib/semmle/javascript/security/dataflow/TaintedFormatStringCustomizations.qll",
542+
"ruby/ql/lib/codeql/ruby/security/TaintedFormatStringCustomizations.qll"
543+
],
544+
"HttpToFileAccessQuery JS/Ruby": [
545+
"javascript/ql/lib/semmle/javascript/security/dataflow/HttpToFileAccessQuery.qll",
546+
"ruby/ql/lib/codeql/ruby/security/HttpToFileAccessQuery.qll"
547+
],
548+
"HttpToFileAccessCustomizations JS/Ruby": [
549+
"javascript/ql/lib/semmle/javascript/security/dataflow/HttpToFileAccessCustomizations.qll",
550+
"ruby/ql/lib/codeql/ruby/security/HttpToFileAccessCustomizations.qll"
510551
]
511552
}

0 commit comments

Comments
 (0)