Skip to content

Commit f83be75

Browse files
authored
feat: codeql pack with trusted owners (#1427)
1 parent 5351309 commit f83be75

File tree

5 files changed

+85
-0
lines changed

5 files changed

+85
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ bin/
5151

5252
# other caches
5353
**/.cache/**
54+
55+
# codeql
56+
**/.codeql/**

codeql/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# CodeQL
2+
3+
Custom CodeQL model packs.
4+
5+
## Development
6+
7+
1. Install codeql CLI
8+
(https://docs.github.com/en/code-security/how-tos/scan-code-for-vulnerabilities/scan-from-the-command-line/setting-up-the-codeql-cli)
9+
10+
```sh
11+
# https://formulae.brew.sh/cask/codeql
12+
brew install --cask codeql
13+
```
14+
15+
### Setup
16+
17+
`codeql pack init`
18+
19+
- https://docs.github.com/en/code-security/tutorials/customize-code-scanning/creating-and-working-with-codeql-packs
20+
21+
## Publishing
22+
23+
1. `cd` into the directory containing the `qlpack.yml` file.
24+
2. If needed, bump the version in the `qlpack.yml`
25+
1. Check versions already published at
26+
https://github.com/orgs/smartcontractkit/packages
27+
3. `gh auth token | codeql pack publish --github-auth-stdin`
28+
29+
## Using
30+
31+
### CodeQL Default
32+
33+
As far as I can tell, there is no way to configure specific repos to use
34+
_separately_ published CodeQL model packs.
35+
36+
You can use model packs declared explicitly in your repository though. If you
37+
wish to do this, follow
38+
[these instructions](https://docs.github.com/en/code-security/how-tos/scan-code-for-vulnerabilities/manage-your-configuration/editing-your-configuration-of-default-setup#extending-codeql-coverage-with-codeql-model-packs-in-default-setup).
39+
40+
#### At the org-level
41+
42+
At the org-level, you can configure all default CodeQL setups to include
43+
specific model packs. See
44+
[these docs](https://docs.github.com/en/code-security/how-tos/scan-code-for-vulnerabilities/manage-your-configuration/editing-your-configuration-of-default-setup#extending-coverage-for-all-repositories-in-an-organization).
45+
46+
### CodeQL Advanced
47+
48+
CodeQL Advanced requires passing in a config or a pack explicitly.
49+
50+
For example:
51+
52+
`.github/codeql/codeql-actions.yml`
53+
54+
```yml
55+
packs:
56+
- smartcontractkit/actions-all-extension@^<version>
57+
58+
queries:
59+
- uses: security-extended
60+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
lockVersion: 1.0.0
3+
dependencies: {}
4+
compiled: false
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# See: https://codeql.github.com/docs/codeql-language-guides/customizing-library-models-for-actions/#example-extend-the-trusted-actions-publishers-for-the-actions-unpinned-tag-query
2+
# I believe the default configuration is here: https://github.com/github/codeql/blob/main/actions/ql/lib/ext/config/trusted_actions_owner.yml
3+
extensions:
4+
- addsTo:
5+
pack: codeql/actions-all
6+
extensible: trustedActionsOwnerDataModel
7+
data:
8+
- ["smartcontractkit"]
9+
- ["actions"]
10+
- ["github"]
11+
- ["advanced-security"]

codeql/actions/qlpack.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: smartcontractkit/actions-all-extension
2+
version: 1.0.0
3+
library: true
4+
extensionTargets:
5+
codeql/actions-all: "*"
6+
dataExtensions:
7+
- models/**/*.yml

0 commit comments

Comments
 (0)