Skip to content

Commit 6c34bd5

Browse files
authored
Merge pull request #30 from OPPIDA/docs/quick-start-guide
2 parents 77fd2db + 2fc5fd9 commit 6c34bd5

File tree

8 files changed

+637
-38
lines changed

8 files changed

+637
-38
lines changed

README.md

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ A framework for code security that provides abstractions for static analysis too
1212
- [Overview](#overview)
1313
- [Features](#features)
1414
- [SAST Tool Integration Status](#sast-tool-integration-status)
15-
- [Installation](#installation)
1615
- [Usage](#usage)
1716
- [Command-line interface](#command-line-interface)
1817
- [Python API](#python-api)
@@ -22,12 +21,14 @@ A framework for code security that provides abstractions for static analysis too
2221

2322
**CodeSecTools** is a collection of scripts and wrappers that abstract external resources (such as SAST tools, datasets, and codebases), providing standardized interfaces to help them interact easily.
2423

25-
For more details on the design and integration of SAST tools and datasets in CodeSecTools, please refer to the [documentation](https://oppida.github.io/CodeSecTools).
26-
2724
<div align="center">
2825
<img src="docs/assets/overview.svg" alt="CodeSecTools Overview" style="width: 75%; height: auto;" />
2926
</div>
3027

28+
For step-by-step instructions on installation, configuration, and basic usage, please refer to the [quick start guide](https://oppida.github.io/CodeSecTools/home/quick_start_guide.html).
29+
30+
For more details on the design and integration of SAST tools and datasets in CodeSecTools, please refer to the [documentation](https://oppida.github.io/CodeSecTools).
31+
3132
## Features
3233

3334
- **Standardized SAST Tool Integration**: Provides a common abstraction layer for integrating various SAST tools. Once a tool is integrated, it automatically benefits from the framework’s core functionalities.
@@ -52,40 +53,6 @@ For more details on the design and integration of SAST tools and datasets in Cod
5253
|SpotBugs|Java|||[Latest PR](https://github.com/OPPIDA/CodeSecTools/actions/workflows/ci.yaml)|
5354
|Cppcheck|C/C++|||[Latest PR](https://github.com/OPPIDA/CodeSecTools/actions/workflows/ci.yaml)|
5455

55-
## Installation
56-
57-
- Clone the repository:
58-
```bash
59-
git clone https://github.com/OPPIDA/CodeSecTools.git
60-
cd CodeSecTools
61-
```
62-
63-
- Install the project:
64-
65-
- Using [uv](https://github.com/astral-sh/uv):
66-
```bash
67-
uv tool install .
68-
```
69-
70-
- Using [pipx](https://github.com/pypa/pipx):
71-
```bash
72-
pipx install .
73-
```
74-
75-
- Using pip (not recommended, as it can break your system packages):
76-
```bash
77-
pip install .
78-
```
79-
80-
- Update the project:
81-
82-
- Pull the latest changes:
83-
```bash
84-
git pull
85-
```
86-
87-
- Reinstall (in case dependencies changed)
88-
8956
## Usage
9057

9158
#### Command-line interface

docs/assets/extra.css

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
}
77

88
/* Custom admonitions */
9+
/* Legal */
910
:root {
1011
--md-admonition-icon--legal: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 10a3.04 3.04 0 0 1 3-3 3.04 3.04 0 0 1 3 3 3.04 3.04 0 0 1-3 3 3.04 3.04 0 0 1-3-3m3 9 4 1v-3.08A7.54 7.54 0 0 1 12 18a7.54 7.54 0 0 1-4-1.08V20m4-16a5.78 5.78 0 0 0-4.24 1.74A5.78 5.78 0 0 0 6 10a5.78 5.78 0 0 0 1.76 4.23A5.78 5.78 0 0 0 12 16a5.78 5.78 0 0 0 4.24-1.77A5.78 5.78 0 0 0 18 10a5.78 5.78 0 0 0-1.76-4.26A5.78 5.78 0 0 0 12 4m8 6a8 8 0 0 1-.57 2.8A7.8 7.8 0 0 1 18 15.28V23l-6-2-6 2v-7.72A7.9 7.9 0 0 1 4 10a7.68 7.68 0 0 1 2.33-5.64A7.73 7.73 0 0 1 12 2a7.73 7.73 0 0 1 5.67 2.36A7.68 7.68 0 0 1 20 10"/></svg>')
1112
}
@@ -27,6 +28,7 @@
2728
mask-image: var(--md-admonition-icon--legal);
2829
}
2930

31+
/* Requirements */
3032
:root {
3133
--md-admonition-icon--requirements: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14 10H3v2h11zm0-4H3v2h11zM3 16h7v-2H3zm18.5-4.5L23 13l-7 7-4.5-4.5L13 14l3 3z"/></svg>')
3234
}
@@ -46,4 +48,70 @@
4648
background-color: rgb(59, 144, 255);
4749
-webkit-mask-image: var(--md-admonition-icon--requirements);
4850
mask-image: var(--md-admonition-icon--requirements);
51+
}
52+
53+
/* Docker */
54+
:root {
55+
--md-admonition-icon--docker: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21.81 10.25c-.06-.04-.56-.43-1.64-.43-.28 0-.56.03-.84.08-.21-1.4-1.38-2.11-1.43-2.14l-.29-.17-.18.27c-.24.36-.43.77-.51 1.19-.2.8-.08 1.56.33 2.21-.49.28-1.29.35-1.46.35H2.62c-.34 0-.62.28-.62.63 0 1.15.18 2.3.58 3.38.45 1.19 1.13 2.07 2 2.61.98.6 2.59.94 4.42.94.79 0 1.61-.07 2.42-.22 1.12-.2 2.2-.59 3.19-1.16A8.3 8.3 0 0 0 16.78 16c1.05-1.17 1.67-2.5 2.12-3.65h.19c1.14 0 1.85-.46 2.24-.85.26-.24.45-.53.59-.87l.08-.24zm-17.96.99h1.76c.08 0 .16-.07.16-.16V9.5c0-.08-.07-.16-.16-.16H3.85c-.09 0-.16.07-.16.16v1.58c.01.09.07.16.16.16m2.43 0h1.76c.08 0 .16-.07.16-.16V9.5c0-.08-.07-.16-.16-.16H6.28c-.09 0-.16.07-.16.16v1.58c.01.09.07.16.16.16m2.47 0h1.75c.1 0 .17-.07.17-.16V9.5c0-.08-.06-.16-.17-.16H8.75c-.08 0-.15.07-.15.16v1.58c0 .09.06.16.15.16m2.44 0h1.77c.08 0 .15-.07.15-.16V9.5c0-.08-.06-.16-.15-.16h-1.77c-.08 0-.15.07-.15.16v1.58c0 .09.07.16.15.16M6.28 9h1.76c.08 0 .16-.09.16-.18V7.25c0-.09-.07-.16-.16-.16H6.28c-.09 0-.16.06-.16.16v1.57c.01.09.07.18.16.18m2.47 0h1.75c.1 0 .17-.09.17-.18V7.25c0-.09-.06-.16-.17-.16H8.75c-.08 0-.15.06-.15.16v1.57c0 .09.06.18.15.18m2.44 0h1.77c.08 0 .15-.09.15-.18V7.25c0-.09-.07-.16-.15-.16h-1.77c-.08 0-.15.06-.15.16v1.57c0 .09.07.18.15.18m0-2.28h1.77c.08 0 .15-.07.15-.16V5c0-.1-.07-.17-.15-.17h-1.77c-.08 0-.15.06-.15.17v1.56c0 .08.07.16.15.16m2.46 4.52h1.76c.09 0 .16-.07.16-.16V9.5c0-.08-.07-.16-.16-.16h-1.76c-.08 0-.15.07-.15.16v1.58c0 .09.07.16.15.16"/></svg>')
56+
}
57+
58+
.md-typeset .admonition.docker,
59+
.md-typeset details.docker {
60+
border-color: rgb(59, 144, 255);
61+
}
62+
63+
.md-typeset .docker>.admonition-title,
64+
.md-typeset .docker>summary {
65+
background-color: rgba(59, 144, 255, 0.1);
66+
}
67+
68+
.md-typeset .docker>.admonition-title::before,
69+
.md-typeset .docker>summary::before {
70+
background-color: rgb(59, 144, 255);
71+
-webkit-mask-image: var(--md-admonition-icon--docker);
72+
mask-image: var(--md-admonition-icon--docker);
73+
}
74+
75+
/* Cube */
76+
:root {
77+
--md-admonition-icon--cube: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M21 16.5c0 .38-.21.71-.53.88l-7.9 4.44c-.16.12-.36.18-.57.18s-.41-.06-.57-.18l-7.9-4.44A.99.99 0 0 1 3 16.5v-9c0-.38.21-.71.53-.88l7.9-4.44c.16-.12.36-.18.57-.18s.41.06.57.18l7.9 4.44c.32.17.53.5.53.88zM12 4.15 6.04 7.5 12 10.85l5.96-3.35z"/></svg>')
78+
}
79+
80+
.md-typeset .admonition.cube,
81+
.md-typeset details.cube {
82+
border-color: rgb(59, 144, 255);
83+
}
84+
85+
.md-typeset .cube>.admonition-title,
86+
.md-typeset .cube>summary {
87+
background-color: rgba(59, 144, 255, 0.1);
88+
}
89+
90+
.md-typeset .cube>.admonition-title::before,
91+
.md-typeset .cube>summary::before {
92+
background-color: rgb(59, 144, 255);
93+
-webkit-mask-image: var(--md-admonition-icon--cube);
94+
mask-image: var(--md-admonition-icon--cube);
95+
}
96+
97+
/* Scan */
98+
:root {
99+
--md-admonition-icon--scan: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17 22v-2h3v-3h2v3.5c0 .4-.2.7-.5 1s-.7.5-1 .5zM7 22H3.5c-.4 0-.7-.2-1-.5s-.5-.7-.5-1V17h2v3h3zM17 2h3.5c.4 0 .7.2 1 .5s.5.6.5 1V7h-2V4h-3zM7 2v2H4v3H2V3.5c0-.4.2-.7.5-1s.6-.5 1-.5zm12 9H5v2h14z"/></svg>')
100+
}
101+
102+
.md-typeset .admonition.scan,
103+
.md-typeset details.scan {
104+
border-color: rgb(63, 70, 79);
105+
}
106+
107+
.md-typeset .scan>.admonition-title,
108+
.md-typeset .scan>summary {
109+
background-color: rgba(59, 144, 255, 0.1);
110+
}
111+
112+
.md-typeset .scan>.admonition-title::before,
113+
.md-typeset .scan>summary::before {
114+
background-color: rgb(63, 70, 79);
115+
-webkit-mask-image: var(--md-admonition-icon--scan);
116+
mask-image: var(--md-admonition-icon--scan);
49117
}

docs/home/quick_start_guide.md

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
# Quick Start Guide
2+
3+
In this section, you will learn how to use CodeSecTools.
4+
5+
This guide mainly used the tool on Java projects, it is perfectly possible to run it on any project that language is supported.
6+
7+
## 1. Prerequisites
8+
9+
For this guide, there are two ways to install the tool:
10+
11+
!!! cube "Normal installation"
12+
- You will need to install the following packages:
13+
14+
- `git`
15+
- `cloc`
16+
- Java Development Kit (17)
17+
- `maven`
18+
19+
- And the following SAST tools:
20+
21+
- [Bearer](/sast/supported/bearer.j2.html){:target="_blank"}
22+
- [Semgrep Community Edition](/sast/supported/semgrepce.j2.html){:target="_blank"}
23+
- [SpotBugs](/sast/supported/spotbugs.j2.html){:target="_blank"}
24+
25+
!!! docker "Docker image"
26+
A Docker image used to run tests is available with the prerequisites installed.
27+
You can use it to test CodeSecTools without installing extra packages on your system.
28+
29+
⚠️ However, this container is intended for running tests, not for normal usage.
30+
Therefore, any data and results inside the container will be deleted when you exit.
31+
32+
Please perform a normal installation if you want to keep your results.
33+
34+
35+
## 2. Installation
36+
37+
!!! cube "Normal installation"
38+
39+
- Clone the repository:
40+
```bash
41+
git clone https://github.com/OPPIDA/CodeSecTools.git
42+
cd CodeSecTools
43+
```
44+
45+
- Install the project:
46+
47+
- Using [uv](https://github.com/astral-sh/uv):
48+
```bash
49+
uv tool install .
50+
```
51+
52+
- Using [pipx](https://github.com/pypa/pipx):
53+
```bash
54+
pipx install .
55+
```
56+
57+
- Using pip (not recommended, as it can break your system packages):
58+
```bash
59+
pip install .
60+
```
61+
62+
!!! docker "Docker image"
63+
To start the Docker container, run the command:
64+
```bash
65+
make test-debug
66+
```
67+
68+
⚠️ The container will be deleted when you exit.
69+
70+
71+
## 3. First run
72+
73+
!!! abstract "Install completion (optional)"
74+
```bash
75+
cstools --install-completion
76+
# For bash
77+
source ~/.bash_completions/cstools.sh
78+
```
79+
80+
!!! abstract "Download external resources"
81+
This command downloads datasets, rules, and plugins required for the SAST tools.
82+
83+
For each external resource, you will be prompted with resource information and, most importantly, its license/term.
84+
```bash
85+
cstools download all
86+
```
87+
88+
!!! abstract "Check the integration status"
89+
This command allows you to check if a SAST tool or dataset is available.
90+
91+
If not, it will specify what is missing.
92+
```bash
93+
cstools status
94+
```
95+
96+
For this guide, the status for Bearer, SemgrepCE, and SpotBugs should be `Full ✅`.
97+
98+
## 4. Common Use Cases
99+
100+
### Analysis with multiple SAST tools
101+
102+
One important feature of CodeSecTools is the ability to run **multiple** SAST tools in order to:
103+
104+
- **aggregate** all the results to take advantage of each SAST tool's strengths (detecting specific vulnerabilities);
105+
- **cross-verify** results and increase the confidence that a finding is a true positive.
106+
107+
Here are some analyses running CodeSecTools on vulnerable projects:
108+
109+
??? scan "cyclonedx-core-java (CVE-2025-64518)"
110+
*Vulnerability details are from [Github Advisory](https://github.com/advisories/GHSA-6fhj-vr9j-g45r).*
111+
112+
- Weakness: [CWE-611](https://cwe.mitre.org/data/definitions/611.html) (Improper Restriction of XML External Entity Reference).
113+
- Introduced in commit [162aa59](https://github.com/CycloneDX/cyclonedx-core-java/commit/162aa594f347b3f612fe0a45071693c3cd398ce9#diff-fc28290f55c35403fc95b45ee2714337621f54b48caba5e01f08d5760b54139a).
114+
- Patched in pull request [#737](https://github.com/CycloneDX/cyclonedx-core-java/pull/737/files#diff-fc28290f55c35403fc95b45ee2714337621f54b48caba5e01f08d5760b54139a).
115+
- Vulnerable file: [`src/main/java/org/cyclonedx/CycloneDxSchema.java`](https://github.com/CycloneDX/cyclonedx-core-java/commit/162aa594f347b3f612fe0a45071693c3cd398ce9#diff-fc28290f55c35403fc95b45ee2714337621f54b48caba5e01f08d5760b54139a).
116+
117+
Download the vulnerable version of the project:
118+
```bash
119+
git clone https://github.com/CycloneDX/cyclonedx-core-java
120+
cd cyclonedx-core-java
121+
git checkout 162aa59
122+
```
123+
124+
Compile the project to generate Java bytecode for SAST tools that require it:
125+
```bash
126+
mvn clean compile
127+
```
128+
129+
Run analysis with all SAST tools:
130+
```bash
131+
cstools allsast analyze java --artifacts target/classes/
132+
```
133+
134+
Generate figures and report:
135+
```bash
136+
cstools allsast plot cyclonedx-core-java
137+
cstools allsast report cyclonedx-core-java
138+
```
139+
140+
Open the project report (`~/.codesectools/output/AllSAST/cyclonedx-core-java/report/home.html`).
141+
142+
The report of the vulnerable file is shown here:
143+
144+
<iframe width="100%" height="500" style="zoom: 0.5;" src="quick_start_guide/cyclonedx-core-java/report.html"></iframe>
145+
146+
Some issues have been found by the tools in the vulnerable file, and the file is ranked high (high score) overall among all other files where issues were found.
147+
148+
SpotBugs is the only tool that detected issues and correctly identified the vulnerability (exact CWE ID).
149+
150+
??? scan "conductor (CVE-2025-26074)"
151+
*Vulnerability details are from [Github Advisory](https://github.com/advisories/GHSA-8gqp-hr9g-pg62).*
152+
153+
- Weakness: [CWE-78](https://cwe.mitre.org/data/definitions/78.html) (Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')).
154+
- Patched in commit [e981650](https://github.com/conductor-oss/conductor/commit/e9816501df1e364a3d39d7fe37d6e167c40eaa1b).
155+
- Vulnerable file: [`core/src/main/java/com/netflix/conductor/core/events/ScriptEvaluator.java`](https://github.com/conductor-oss/conductor/blob/main/core/src/main/java/com/netflix/conductor/core/events/ScriptEvaluator.java).
156+
- *Note: the patch did not modify the vulnerable file but other files, which attenuated the vulnerability.*
157+
158+
Download the vulnerable version of the project:
159+
```bash
160+
git clone https://github.com/conductor-oss/conductor
161+
cd conductor
162+
git checkout 5976cad
163+
```
164+
165+
Compile the project to generate Java bytecode for SAST tools that require it:
166+
```bash
167+
./gradlew compileJava
168+
```
169+
170+
Run analysis with all SAST tools:
171+
```bash
172+
cstools allsast analyze java --artifacts .
173+
```
174+
175+
Generate figures and report:
176+
```bash
177+
cstools allsast plot conductor
178+
cstools allsast report conductor
179+
```
180+
181+
Open the project report (`~/.codesectools/output/AllSAST/conductor/report/home.html`).
182+
183+
The report of the vulnerable file is shown here:
184+
185+
<iframe width="100%" height="500" style="zoom: 0.5;" src="quick_start_guide/conductor/report.html"></iframe>
186+
187+
Only one issue has been found by the tools in the vulnerable file, and the file is ranked low (low score) overall among all other files where issues were found.
188+
189+
SemgrepCE is the only tool that detected issues and partially identified the vulnerability.
190+
It has detected a `code injection` that could leads to an `OS command injection`.
191+
192+
*Note: If we did not know that a vulnerability existed, we would have had to verify it (by attempting to exploit it) because the `eval` function is a feature.*
193+
194+
### Benchmarking SAST tool
195+
196+
It is possible to benchmark any SAST tool on any dataset that are integrated to CodeSecTools thanks to the prior integration:
197+
198+
```bash
199+
cstools spotbugs benchmark BenchmarkJava_java
200+
```
201+
202+
If the SAST tool requires artifacts, the expected artifacts and build command are provided:
203+
204+
```bash
205+
cstools spotbugs benchmark BenchmarkJava_java
206+
╭──────────────────────── SpotBugs - PrebuiltSAST ────────────────────────╮
207+
│ │
208+
│ Please build BenchmarkJava before running the benchmark │
209+
│ Build command: mvn clean compile │
210+
│ Full command: (cd │
211+
│ /home/michel/.codesectools/cache/BenchmarkJava && mvn clean compile) │
212+
│ Expected arteficts: │
213+
│ /home/michel/.codesectools/cache/BenchmarkJava/target/classes/org/owasp │
214+
│ /benchmark/testcode/*.class │
215+
╰─────────────────────────────────────────────────────────────────────────╯
216+
```
217+
218+
Then generating figures using the analysis output:
219+
220+
```bash
221+
cstools spotbugs plot BenchmarkJava_java --overwrite
222+
Figure overview saved at /home/michel/.codesectools/output/SpotBugs/BenchmarkJava_java/_figures/overview.png
223+
Figure top_cwes saved at /home/michel/.codesectools/output/SpotBugs/BenchmarkJava_java/_figures/top_cwes.png
224+
```
225+
226+
Figures:
227+
228+
![Overview](quick_start_guide/benchmark/overview.png)
229+
230+
![Top CWEs](quick_start_guide/benchmark/top_cwes.png)
110 KB
Loading
98.9 KB
Loading

0 commit comments

Comments
 (0)