Skip to content

Commit c06ccf9

Browse files
committed
Audit is finally here!
1 parent d73f6fd commit c06ccf9

File tree

8 files changed

+67
-42
lines changed

8 files changed

+67
-42
lines changed

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"arithmatex",
44
"ckers",
55
"cking",
6+
"crossplatform",
7+
"crossruntime",
68
"fkadd",
9+
"fkaudit",
710
"fkclean",
811
"fkcommit",
912
"fklaunch",
@@ -22,6 +25,7 @@
2225
"personaplus",
2326
"pkgs",
2427
"preapp",
28+
"pymdownx",
2529
"sokora",
2630
"therf",
2731
"vuelto",

docs/about/roadmap.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ We'll expand (and rarely, but not impossibly, shrink) this roadmap as we make pr
88

99
## Upcoming release
1010

11-
- [ ] Rewrite the `audit` feature.
12-
- [ ] Fix known issues.
13-
- [ ] Expand vector string lists & question list.
11+
- [X] Rewrite the `audit` feature.
12+
- [X] Fix known issues.
1413
- [x] Support it everywhere NodeJS
1514
- [x] pnpm
1615
- [x] yarn

docs/install.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Function New-Shortcuts {
6868
"fkadd" = "manager add"
6969
"fkrem" = "manager remove"
7070
"fklist" = "manager list"
71+
"fkaudit" = "audit"
7172
}
7273

7374
foreach ($name in $commands.Keys) {

docs/install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ create_shortcuts() {
125125
["fkadd"]="manager add"
126126
["fkrem"]="manager remove"
127127
["fklist"]="manager list"
128+
["fkaudit"]="audit"
128129
)
129130

130131
for name in "${!commands[@]}"; do

docs/learn/audit.md

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22

33
An attempt to make security reports easier.
44

5-
!!! danger "Outdated"
6-
**This section will not be updated until V3.3**. To prevent updates from taking ages, as we've recently planned a full rewrite of this feature, we will not waste our time on fixing a feature that is not considered stable for use anyway.
7-
**Avoid using audit as of now.**
8-
9-
!!! danger "Work in Progress feature"
10-
This is an **experimental** feature. It is subject to changes, full rewrites, or even removals.
11-
125
## Abstract
136

147
We will explain this with a real life example - I, the creator of F\*ckingNode, have been working on a mobile React Native app, which once became affected by a `low` severity vulnerability, related to cookies. The thing is, fixing it implied breaking changes (as `expo-router` had a dependency that had a dependency that had a... until one that depended on the vulnerable version).
@@ -23,8 +16,6 @@ However, as a mobile app that never interacted with cookies and very rarely used
2316

2417
## How it works
2518

26-
> AGAIN, THIS IS AN UNFINISHED, NON-RELEASED FEATURE.
27-
2819
The process is as follows:
2920

3021
- We analyze your vulnerabilities
@@ -38,21 +29,27 @@ Due to where nowadays society is heading, it _is_ worth noting questions are not
3829

3930
```mermaid
4031
graph TD
41-
A[npm audit] -->|Command execution| B[Returns report string]
42-
B -->|Parsed| C[Stored in ParsedNpmReport]
43-
C -->|For each dependency| D[Fetch info from OSV.dev and store it]
32+
A[fkaudit] -->|Command execution| B[Runs platform-specific audit command]
33+
B -->|Parse JSON output| C[Stores text in a SV_KEYWORDS object]
34+
B -->|Parse JSON output| G[Stores severities separately]
35+
C -->|Analyzed| D[Questions asked to the user]
36+
D -->|Analyzed, too| E[RF computed]
37+
E -->|RF pondered| H(Final RISK FACTOR)
38+
G -->|Numeric associations made| J[SB and SDB computed]
39+
J -->|Used to ponder RF| H
40+
H -->|Basic equation done| K[Human readable percentage and text result given to the end user]
4441
```
4542

46-
We regularly audit your project and rely on `https://api.osv.dev` to get more details onto what is it about. After that, a more detailed analysis is made where we obtain **key questions** based on vectors.
43+
We perform a regular audit your project, and then we realize a keyword analysis from where we obtain **key questions** based on vectors.
4744

4845
```mermaid
4946
graph TD
50-
A[ParsedNpmReport] -->|For each vulnerability| B[Pass key data to analyzer function]
47+
A[ParsedNodeReport] -->|For each vulnerability| B[Pass key data to analyzer function]
5148
B -->|Search for attack vectors via keywords| C(Keyword / vector found?)
5249
C -- Yes --> D[Return 'beginner question' based on attack vector] --> F
5350
C -- No --> E[No return] --> F
5451
F[Was that the last one?]
55-
F -- Yes --> G[Audit complete]
52+
F -- Yes --> G[Questions ready for auditing]
5653
F -- No --> B
5754
```
5855

@@ -72,30 +69,44 @@ graph TD
7269
F -->|NO| H[Audit results are ready by this point.]
7370
```
7471

75-
### Step three: evaluation
76-
77-
Your questions are evaluated using a straightforward positive-negative system: responses indicating 'positive' information add +1 to the positive count, while those indicating 'negative' information add +1 to the negative count.
72+
Each question returns either `+1` or `+2` to be added to either the positive count or the negative count, as described right below.
7873

79-
These counts are used to compute the RF, based on the following formula:
80-
81-
$$
82-
R.F. = \left( \frac{\text{positives}}{\text{positives} + \text{negatives}} \right) \times 100
83-
$$
84-
85-
There is a `--strict` flag that can be passed to the audit command that adds an additional **risk bump**, based on the severity of the most-severe identified vulnerability, as follows:
86-
87-
$$
88-
Strict R.F. = \frac{R.F. + (R.B. \times 100)}{2}
89-
$$
90-
91-
RB values are as follows:
74+
### Step three: evaluation
9275

93-
| Severity | RB |
94-
| :------- | ---: |
95-
| critical | 1 |
96-
| high | 0.75 |
97-
| moderate | 0.5 |
98-
| low | 0.25 |
76+
Your questions are evaluated using a straightforward positive-negative system: responses indicating 'positive' information add up to the positive count, while those indicating 'negative' information add up to the negative count.
77+
78+
These counts and the SB and SDB values are used to compute the RF, a risk percentage where 0 means _safe to ignore security updates_ and 100 means _absolutely necessary to perform security updates_. The RF is computed based on the following formula. It is worth noting that, because of the unreliability of a non-human scan, we take a more complex approach so that we can intentionally increase the RF by pure mathematic means, using the SB and SDB.
79+
80+
\[
81+
T = P + (N \cdot S_d)
82+
\]
83+
84+
\[
85+
\text{RF} =
86+
\begin{cases}
87+
0, & \text{if } T = 0 \\
88+
\min\left(100, \max\left(0, \dfrac{N \cdot S_b}{T} \cdot 100\right)\right), & \text{otherwise}
89+
\end{cases}
90+
\]
91+
92+
\[
93+
\text{where:} \quad
94+
\begin{aligned}
95+
P &= \text{positives} \\
96+
N &= \text{negatives} \\
97+
S_d &= \text{severityDeBump (indirectly bumps RF)} \\
98+
S_b &= \text{severityBump (directly bumps RF)}
99+
\end{aligned}
100+
\]
101+
102+
SB and SDB values are as follows:
103+
104+
| Severity | SB | SDB |
105+
| :------- | ---: | ---: |
106+
| critical | 2.00 | 0.25 |
107+
| high | 1.75 | 0.50 |
108+
| moderate | 1.50 | 0.75 |
109+
| low | 1.25 | 1.00 |
99110

100111
---
101112

@@ -115,4 +126,5 @@ Where `EXP` indicates experimental, `CAVEAT` indicates partial support / support
115126
| v2.1.0 | EXP | NO | NO | NO | NO | NO | NO |
116127

117128
*[RF]: Risk Factor; a percentage computed by us to estimate the joint impact of all vulnerabilities of a NodeJS project.
118-
*[RB]: Risk Bump; a 0.25-1 number that's used to bump the RF based on the highest severity (as in low/moderate/high/critical) of a found vulnerability within a project.
129+
*[SB]: Severity Bump; a 1.25-2 number that's used to bump the RF based on the highest severity (as in low/moderate/high/critical) of a found vulnerability within a project.
130+
*[SDB]: Severity DeBump; a 0.25-1 number that's used to de-bump the negative count prior computing the RF based on the highest severity (as in low/moderate/high/critical) of a found vulnerability within a project.

docs/learn/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ Only features worth including are mentioned - not because other features are wor
1111
## Table of Contents
1212

1313
- [Clean](clean.md)
14-
- [(Experimental) Audit](audit.md)
14+
- [Audit](audit.md)

docs/manual/audit.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Using FuckingNode: Audit a project
2+
3+
> `fuckingnode audit [project-name]`
4+
5+
The `audit` command is a command that automatically runs a security audit for a project you specify (or for all projects if no name is specified), and interrogates security vulnerabilities (if any) to determine if they're worth fixing.
6+
7+
This is better explained [here](../learn/audit.md).

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ nav:
2727
- Extra - Setup: "manual/setup.md"
2828
- Extra - Stats: "manual/stats.md"
2929
- Extra - Surrender: "manual/surrender.md"
30+
- Extra - Audit: "manual/audit.md"
3031
- Learn - Cross-runtime support: "learn/cross-runtime-support.md"
3132
- "What's next?": "manual/whats-next.md"
3233

0 commit comments

Comments
 (0)