1
- # gh-codeql-scan
1
+ <!-- markdownlint-disable -->
2
+ <div align =" center " >
2
3
3
- GitHub CLI CodeQL Scan Extension to help abstract CodeQL away from users.
4
+ <h1 >gh-codeql-scan</h1 >
5
+
6
+ [ ![ GitHub] ( https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white )] [ github ]
7
+ [ ![ GitHub Issues] ( https://img.shields.io/github/issues/advanced-security/gh-codeql-scan?style=for-the-badge )] [ github-issues ]
8
+ [ ![ GitHub Stars] ( https://img.shields.io/github/stars/advanced-security/gh-codeql-scan?style=for-the-badge )] [ github ]
9
+ [ ![ License] ( https://img.shields.io/github/license/advanced-security/gh-codeql-scan?style=for-the-badge )] [ license ]
10
+
11
+ </div >
12
+ <!-- markdownlint-restore -->
13
+
14
+ [ GitHub CLI CodeQL Scan Extension] [ github ] to help abstract [ CodeQL] [ codeql ] away from users.
15
+
16
+ <details >
17
+ <summary >Motivation</summary >
18
+
19
+ This project was created to make the lives of users that use CodeQL simpiler.
20
+ CodeQL outside of GitHub Actions can be complicated but this projects aim is to make it as simple as possible.
21
+
22
+ </details >
4
23
5
24
## Requirements
6
25
7
26
- [ GitHub CLI] ( https://cli.github.com/ )
27
+ - [ CodeQL GH Extension] [ gh-codeql ] (optional)
8
28
9
29
## Install and Setup
10
30
@@ -17,9 +37,59 @@ gh extensions install advanced-security/gh-codeql-scan
17
37
gh codeql-scan --help
18
38
```
19
39
40
+ <details >
41
+ <summary >CLI Help</summary >
42
+
43
+ <pre >
44
+ GitHub CodeQL Scan tool
45
+
46
+ gh codeql-scan {MODE} {ARGS}
47
+
48
+ # Modes
49
+
50
+ gh codeql-scan # default: "scan"
51
+ gh codeql-scan init # initialise the scan
52
+ gh codeql-scan analyze # run the analysis
53
+ gh codeql-scan upload # upload present SARIF files
54
+ gh codeql-scan scan # full end-to-end scan
55
+
56
+ # Arguments
57
+
58
+ > All arguments can be set with enviroment variables
59
+
60
+ -h|--help # Print help
61
+ --debug # Enable debugging
62
+
63
+ -r=*|--repo=* # GitHub Respository (OWNER/NAME)
64
+ -i=*|--instance=* # GitHub Instance (github.com or Enterprise Server)
65
+
66
+ -l=*|--language=* # Set language to scan
67
+ --auto-detect # Auto-detect languages
68
+
69
+ -s=*|--suite=* # Query Suite to use
70
+ -d=*|--databases=* # Location of the databases to store
71
+ -b=*|--binary=* # Path to the CodeQL Binary
72
+ -w=*|--workspace=* # Workspace for the souce code
73
+
74
+ -c=*|--command=* # Set the build comment (compiled languages)
75
+ -m=*|--mode=* # Build mode (autobuild | none)
76
+ --buildless # Enable buildless / build mode none
77
+
78
+ --view-in-vscode # Auto-open the results in VSCode
79
+
80
+ --disable-tracing # Disable Build Tracing
81
+ --disable-trap-caching # Disable Trap file caching
82
+ --disable-upload # Disable Uploading SARIF to GitHub
83
+ --disable-banner # Disable printing banner
84
+ </pre >
85
+
86
+ </details >
87
+
88
+ ### Alias / Stub
89
+
20
90
A couple of tips and tricks:
21
91
22
- ```
92
+ ``` bash
23
93
# Create an alias to make things even easier
24
94
alias codeql-scan=" gh codeql-scan"
25
95
```
@@ -33,46 +103,79 @@ The main use of the script is to automatically run CodeQL in a number of modes.
33
103
gh codeql-scan
34
104
```
35
105
106
+ #### Initialise with language
107
+
108
+ Automatically detect languages or manually set the language to create an initial CodeQL database.
109
+
36
110
``` bash
37
- # `init` mode: Create only the Codeql database
38
111
gh codeql-scan init --auto-detect
39
112
# or manually set language
40
113
gh codeql-scan init -l=java
41
114
```
42
115
116
+ #### Scan without build
117
+
118
+ This will scan your code in build mode ` none ` .
119
+
120
+ ``` bash
121
+ gh codeql-scan -m=" none"
122
+ # or simply
123
+ gh codeql-scan --buildless
124
+ ```
125
+
126
+ #### Scan with Build Command
127
+
128
+ Pass in the build command for a compiled language and it will be run along with CodeQL.
129
+
43
130
``` bash
44
- # Compiled languages - pass in build command
45
131
gh codeql-scan -c " mvn build ..."
46
132
```
47
133
134
+ #### Indirect build tracing
135
+
136
+ For Compiled languages, complicated build process using indirect build tracing
137
+
48
138
``` bash
49
- # Compiled languages - complicated build process using indirect build tracing
50
139
gh codeql-scan init
51
140
echo " password=$password " > settings.xml
52
141
mvn build --random-custom=flags
53
142
gh codeql-scan analyze
54
143
```
55
144
145
+ #### Running analysis
146
+
147
+ Run query-suites on an existing database (auto-detects databases)
148
+
56
149
``` bash
57
- # `analyze` mode: Run query-suites on an existing database (auto-detects databases)
58
150
gh codeql-scan analyze
59
151
```
60
152
153
+ #### Uploading results to GitHub
154
+
155
+ The ` upload ` mode will upload all SARIF files for you to a repository
156
+
61
157
``` bash
62
- # `upload` mode: Upload all SARIF files
63
158
gh codeql-scan upload
64
159
```
65
160
66
- ## License
67
-
68
- This project is licensed under the terms of the MIT open source license. Please refer to [ MIT] ( ./LICENSE.md ) for the full terms.
69
-
70
161
## Maintainers
71
162
72
163
- @GeekMasher
73
164
74
- ## Support
165
+ ## Support / Maintainance
166
+
167
+ Support is via [ GitHub Issues] [ github-issues ]
168
+
169
+ ## License
170
+
171
+ This project is licensed under the terms of the MIT open source license.
172
+ Please refer to [ MIT] [ license ] for the full terms.
173
+
174
+ <!-- Resources -->
75
175
76
- Support is via [ GitHub Issues] ( https://github.com/advanced-security/gh-codeql-scan/issues )
176
+ [ license ] : ./LICENSE
177
+ [ github ] : https://github.com/advanced-security/gh-codeql-scan
178
+ [ github-issues ] : https://github.com/advanced-security/gh-codeql-scan/issues
179
+ [ codeql ] : https://codeql.github.com/
180
+ [ gh-codeql ] : https://github.com/github/gh-codeql
77
181
78
- ## Acknowledgement
0 commit comments