Skip to content

Commit 88bd6d6

Browse files
authored
Merge pull request #41801 from github/repo-sync
Repo sync
2 parents c4593a0 + 568a220 commit 88bd6d6

Some content is hidden

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

59 files changed

+3810
-415
lines changed

.github/workflows/generate-code-scanning-query-lists.yml

Lines changed: 117 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ on:
1919
pull_request:
2020
paths:
2121
- .github/workflows/generate-code-scanning-query-lists.yml
22-
- src/code-scanning/scripts/generate-code-scanning-query-list.ts
22+
- src/codeql-queries/scripts/generate-code-scanning-query-list.ts
23+
- src/codeql-queries/scripts/generate-code-quality-query-list.ts
2324
- .github/actions/install-cocofix/action.yml
2425

2526
permissions:
2627
contents: write
2728
pull-requests: write
2829

2930
jobs:
30-
generate-query-lists:
31+
generate-security-query-lists:
3132
if: github.repository == 'github/docs-internal'
3233
runs-on: ubuntu-latest
3334
steps:
@@ -45,6 +46,7 @@ jobs:
4546

4647
- name: Get the codeql SHA being synced
4748
id: codeql
49+
shell: bash
4850
run: |
4951
cd codeql
5052
OPENAPI_COMMIT_SHA=$(git rev-parse HEAD)
@@ -56,12 +58,14 @@ jobs:
5658
uses: ./codeql/.github/actions/fetch-codeql
5759

5860
- name: Test CodeQL CLI Download
61+
shell: bash
5962
run: codeql --version
6063

6164
# "Server for running multiple commands while avoiding repeated JVM initialization."
6265
# Having started this should speed up the execution of the various
6366
# CLI calls of the executable.
6467
- name: Start CodeQL CLI server in the background
68+
shell: bash
6569
run: |
6670
codeql execute cli-server &
6771
sleep 3
@@ -71,21 +75,8 @@ jobs:
7175
with:
7276
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
7377

74-
- name: Lint the code (eslint)
75-
if: ${{ github.event_name == 'pull_request' }}
76-
env:
77-
PATH: '$PATH:${{ github.workspace }}/node_modules/.bin'
78-
run: |
79-
eslint --no-ignore src/code-scanning/scripts/generate-code-scanning-query-list.ts
80-
81-
- name: Lint the code (tsc)
82-
if: ${{ github.event_name == 'pull_request' }}
83-
env:
84-
PATH: '$PATH:${{ github.workspace }}/node_modules/.bin'
85-
run: |
86-
tsc --noEmit --project src/code-scanning/scripts/tsconfig.json
87-
88-
- name: Build code scanning query list
78+
- name: Build code scanning security query lists
79+
shell: bash
8980
run: |
9081
for lang in "actions" "cpp" "csharp" "go" "java" "javascript" "python" "ruby" "rust" "swift"; do
9182
echo "Generating code scanning query list for $lang"
@@ -97,14 +88,120 @@ jobs:
9788
$lang
9889
done
9990
91+
- name: Upload security query lists
92+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
93+
with:
94+
name: security-query-lists
95+
path: data/reusables/code-scanning/codeql-query-tables/
96+
97+
generate-quality-query-lists:
98+
if: github.repository == 'github/docs-internal'
99+
runs-on: ubuntu-latest
100+
steps:
101+
- name: Checkout repository code
102+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
103+
104+
- uses: ./.github/actions/node-npm-setup
105+
106+
- name: Checkout codeql repo
107+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
108+
with:
109+
repository: github/codeql
110+
path: codeql
111+
ref: ${{ inputs.SOURCE_BRANCH || 'main' }}
112+
113+
- name: Get the codeql SHA being synced
114+
id: codeql
115+
shell: bash
116+
run: |
117+
cd codeql
118+
OPENAPI_COMMIT_SHA=$(git rev-parse HEAD)
119+
echo "OPENAPI_COMMIT_SHA=$OPENAPI_COMMIT_SHA" >> $GITHUB_OUTPUT
120+
echo "Copied files from github/codeql repo. Commit SHA: $OPENAPI_COMMIT_SHA"
121+
122+
- name: Download CodeQL CLI
123+
# Look under the `codeql` directory, as this is where we checked out the `github/codeql` repo
124+
uses: ./codeql/.github/actions/fetch-codeql
125+
126+
- name: Test CodeQL CLI Download
127+
shell: bash
128+
run: codeql --version
129+
130+
# "Server for running multiple commands while avoiding repeated JVM initialization."
131+
# Having started this should speed up the execution of the various
132+
# CLI calls of the executable.
133+
- name: Start CodeQL CLI server in the background
134+
shell: bash
135+
run: |
136+
codeql execute cli-server &
137+
sleep 3
138+
codeql --version
139+
140+
- name: Build code quality query lists
141+
shell: bash
142+
run: |
143+
for lang in "csharp" "go" "java" "javascript" "python" "ruby"; do
144+
echo "Generating code quality query list for $lang"
145+
npm run generate-code-quality-query-list -- \
146+
--verbose \
147+
--codeql-path codeql \
148+
--codeql-dir codeql \
149+
-o data/reusables/code-quality/codeql-query-tables/$lang.md \
150+
$lang
151+
done
152+
153+
- name: Upload quality query lists
154+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
155+
with:
156+
name: quality-query-lists
157+
path: data/reusables/code-quality/codeql-query-tables/
158+
159+
create-pull-request:
160+
if: github.repository == 'github/docs-internal'
161+
runs-on: ubuntu-latest
162+
needs: [generate-security-query-lists, generate-quality-query-lists]
163+
steps:
164+
- name: Checkout repository code
165+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
166+
167+
- name: Checkout codeql repo
168+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
169+
with:
170+
repository: github/codeql
171+
path: codeql
172+
ref: ${{ inputs.SOURCE_BRANCH || 'main' }}
173+
174+
- name: Get the codeql SHA being synced
175+
id: codeql
176+
shell: bash
177+
run: |
178+
cd codeql
179+
OPENAPI_COMMIT_SHA=$(git rev-parse HEAD)
180+
echo "OPENAPI_COMMIT_SHA=$OPENAPI_COMMIT_SHA" >> $GITHUB_OUTPUT
181+
echo "Copied files from github/codeql repo. Commit SHA: $OPENAPI_COMMIT_SHA"
182+
183+
- name: Download security query lists
184+
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
185+
with:
186+
name: security-query-lists
187+
path: data/reusables/code-scanning/codeql-query-tables/
188+
189+
- name: Download quality query lists
190+
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
191+
with:
192+
name: quality-query-lists
193+
path: data/reusables/code-quality/codeql-query-tables/
194+
100195
- name: Insight into diff
196+
shell: bash
101197
run: |
102198
git diff
103199
104200
- name: Create pull request
105201
env:
106202
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }}
107203
DRY_RUN: ${{ github.event_name == 'pull_request'}}
204+
shell: bash
108205
run: |
109206
110207
# When we started, we downloaded the CodeQL CLI here in this workflow.
@@ -145,6 +242,7 @@ jobs:
145242
fi
146243
147244
git add data/reusables/code-scanning/codeql-query-tables
245+
git add data/reusables/code-quality/codeql-query-tables
148246
git commit -m "Update CodeQL query tables"
149247
git push -u origin $branchname
150248
@@ -157,6 +255,6 @@ jobs:
157255
158256
159257
No action is required from the first responder for the Docs content team. This PR is automatically added to the Docs content review board. Any writer can review this by checking that the PR looks sensible. If CI does not pass or other problems arise, contact #docs-engineering on slack.
160-
161-
258+
259+
162260
When the DRI for the CodeQL CLI release is ready to publish, they will ask us to merge this PR in #docs-content.'

content/code-security/code-quality/reference/codeql-detection.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
2-
title: CodeQL detection of code quality problems
3-
shortTitle: CodeQL detection
2+
title: CodeQL-powered analysis for Code Quality
3+
shortTitle: CodeQL analysis
4+
allowTitleToDifferFromFilename: true
45
intro: 'Information on how CodeQL-powered analysis for {% data variables.product.prodname_code_quality_short %} works, the workflow used, and the status checks reported on pull requests.'
56
versions:
67
feature: code-quality
@@ -11,11 +12,30 @@ contentType: reference
1112

1213
{% data reusables.code-quality.code-quality-preview-note %}
1314

14-
## {% data variables.product.prodname_codeql %} detection
15+
## {% data variables.product.prodname_codeql %}-powered analysis
1516

16-
{% data variables.product.prodname_code_quality_short %} performs rule-based analysis of pull requests and your default branch using {% data variables.product.prodname_codeql %}. Each rule is written as a query in {% data variables.product.prodname_codeql %} and then run using {% data variables.product.prodname_actions %}.
17+
{% data variables.product.prodname_code_quality_short %} uses {% data variables.product.prodname_codeql %} to perform rule-based analysis of pull requests and your default branch.
1718

18-
The rules are continually refined by both {% data variables.product.github %} and open source developers. See [https://github.com/github/codeql](https://github.com/github/codeql).
19+
* Findings for your **default branch** appear under the "{% data variables.code-quality.all_findings %}" dashboard under your repository's Security tab.
20+
21+
* Findings **on pull requests** appear as comments made by `{% data variables.code-quality.pr_commenter %}`.
22+
23+
{% data variables.copilot.copilot_autofix_short %} suggestions are provided for findings where possible.
24+
25+
### Query lists for supported languages
26+
27+
Each {% data variables.product.prodname_code_quality_short %} rule is written as a query in {% data variables.product.prodname_codeql %} and then run using {% data variables.product.prodname_actions %}.
28+
29+
The rules are continually refined by both {% data variables.product.github %} and open source developers.
30+
31+
* [AUTOTITLE](/code-security/code-quality/reference/codeql-queries/csharp-queries)
32+
* [AUTOTITLE](/code-security/code-quality/reference/codeql-queries/go-queries)
33+
* [AUTOTITLE](/code-security/code-quality/reference/codeql-queries/java-queries)
34+
* [AUTOTITLE](/code-security/code-quality/reference/codeql-queries/javascript-queries)
35+
* [AUTOTITLE](/code-security/code-quality/reference/codeql-queries/python-queries)
36+
* [AUTOTITLE](/code-security/code-quality/reference/codeql-queries/ruby-queries)
37+
38+
For more information about the {% data variables.product.prodname_codeql %} project, see [https://codeql.github.com/](https://codeql.github.com/).
1939

2040
## Workflow used for code quality analysis
2141

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: C# CodeQL queries for Code Quality
3+
shortTitle: C# queries
4+
allowTitleToDifferFromFilename: true
5+
intro: 'Explore the queries that {% data variables.product.prodname_codeql %} uses to analyze code quality for code written in C#.'
6+
versions:
7+
feature: code-quality
8+
topics:
9+
- Code Quality
10+
contentType: reference
11+
---
12+
13+
{% data variables.product.prodname_code_quality_short %} uses the following {% data variables.product.prodname_codeql %} queries to analyze C# code and detect code quality issues on:
14+
15+
* Your **default branch**, with results shown on the repository's "{% data variables.code-quality.all_findings %}" dashboard
16+
* **Pull requests**, with findings shown as comments made by `{% data variables.code-quality.pr_commenter %}`
17+
18+
{% data variables.copilot.copilot_autofix_short %} suggestions are provided for findings where possible.
19+
20+
{% data reusables.code-quality.codeql-query-tables.csharp %}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: Go CodeQL queries for Code Quality
3+
shortTitle: Go queries
4+
intro: 'Explore the queries that {% data variables.product.prodname_codeql %} uses to analyze code quality for code written in Go.'
5+
versions:
6+
feature: code-quality
7+
topics:
8+
- Code Quality
9+
contentType: reference
10+
---
11+
12+
{% data variables.product.prodname_code_quality_short %} uses the following {% data variables.product.prodname_codeql %} queries to analyze Go code and detect code quality issues on:
13+
14+
* Your **default branch**, with results shown on the repository's "{% data variables.code-quality.all_findings %}" dashboard
15+
* **Pull requests**, with findings shown as comments made by `{% data variables.code-quality.pr_commenter %}`
16+
17+
{% data variables.copilot.copilot_autofix_short %} suggestions are provided for findings where possible.
18+
19+
{% data reusables.code-quality.codeql-query-tables.go %}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Queries for CodeQL detection
3+
shortTitle: CodeQL queries
4+
intro: 'Explore the {% data variables.product.prodname_codeql %} queries that {% data variables.product.prodname_code_quality_short %} uses to detect code quality issues in supported languages.'
5+
versions:
6+
feature: code-quality
7+
topics:
8+
- Code Quality
9+
contentType: reference
10+
children:
11+
- csharp-queries
12+
- go-queries
13+
- java-queries
14+
- javascript-queries
15+
- python-queries
16+
- ruby-queries
17+
---
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: Java CodeQL queries for Code Quality
3+
shortTitle: Java queries
4+
allowTitleToDifferFromFilename: true
5+
intro: 'Explore the queries that {% data variables.product.prodname_codeql %} uses to analyze code quality for code written in Java.'
6+
versions:
7+
feature: code-quality
8+
topics:
9+
- Code Quality
10+
contentType: reference
11+
---
12+
13+
{% data variables.product.prodname_code_quality_short %} uses the following {% data variables.product.prodname_codeql %} queries to analyze Java code and detect code quality issues on:
14+
15+
* Your **default branch**, with results shown on the repository's "{% data variables.code-quality.all_findings %}" dashboard
16+
* **Pull requests**, with findings shown as comments made by `{% data variables.code-quality.pr_commenter %}`
17+
18+
{% data variables.copilot.copilot_autofix_short %} suggestions are provided for findings where possible.
19+
20+
{% data reusables.code-quality.codeql-query-tables.java %}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: JavaScript CodeQL queries for Code Quality
3+
shortTitle: JavaScript queries
4+
allowTitleToDifferFromFilename: true
5+
intro: 'Explore the queries that {% data variables.product.prodname_codeql %} uses to analyze code quality for code written in JavaScript.'
6+
versions:
7+
feature: code-quality
8+
topics:
9+
- Code Quality
10+
contentType: reference
11+
---
12+
13+
{% data variables.product.prodname_code_quality_short %} uses the following {% data variables.product.prodname_codeql %} queries to analyze JavaScript code and detect code quality issues on:
14+
15+
* Your **default branch**, with results shown on the repository's "{% data variables.code-quality.all_findings %}" dashboard
16+
* **Pull requests**, with findings shown as comments made by `{% data variables.code-quality.pr_commenter %}`
17+
18+
{% data variables.copilot.copilot_autofix_short %} suggestions are provided for findings where possible.
19+
20+
{% data reusables.code-quality.codeql-query-tables.javascript %}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: Python CodeQL queries for Code Quality
3+
shortTitle: Python queries
4+
allowTitleToDifferFromFilename: true
5+
intro: 'Explore the queries that {% data variables.product.prodname_codeql %} uses to analyze code quality for code written in Python.'
6+
versions:
7+
feature: code-quality
8+
topics:
9+
- Code Quality
10+
contentType: reference
11+
---
12+
13+
{% data variables.product.prodname_code_quality_short %} uses the following {% data variables.product.prodname_codeql %} queries to analyze Python code and detect code quality issues on:
14+
15+
* Your **default branch**, with results shown on the repository's "{% data variables.code-quality.all_findings %}" dashboard
16+
* **Pull requests**, with findings shown as comments made by `{% data variables.code-quality.pr_commenter %}`
17+
18+
{% data variables.copilot.copilot_autofix_short %} suggestions are provided for findings where possible.
19+
20+
{% data reusables.code-quality.codeql-query-tables.python %}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: Ruby CodeQL queries for Code Quality
3+
shortTitle: Ruby queries
4+
allowTitleToDifferFromFilename: true
5+
intro: 'Explore the queries that {% data variables.product.prodname_codeql %} uses to analyze code quality for code written in Ruby.'
6+
versions:
7+
feature: code-quality
8+
topics:
9+
- Code Quality
10+
contentType: reference
11+
---
12+
13+
{% data variables.product.prodname_code_quality_short %} uses the following {% data variables.product.prodname_codeql %} queries to analyze Ruby code and detect code quality issues on:
14+
15+
* Your **default branch**, with results shown on the repository's "{% data variables.code-quality.all_findings %}" dashboard
16+
* **Pull requests**, with findings shown as comments made by `{% data variables.code-quality.pr_commenter %}`
17+
18+
{% data variables.copilot.copilot_autofix_short %} suggestions are provided for findings where possible.
19+
20+
{% data reusables.code-quality.codeql-query-tables.ruby %}

content/code-security/code-quality/reference/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ contentType: reference
1010
children:
1111
- metrics-and-ratings
1212
- codeql-detection
13+
- codeql-queries
1314
---

0 commit comments

Comments
 (0)