Skip to content
This repository was archived by the owner on Apr 9, 2024. It is now read-only.

Commit 4b43e9f

Browse files
CWE mappings for findings (#43)
* update finding types to refer to CWE id * fix the broken tests
1 parent 0dbd84d commit 4b43e9f

File tree

10 files changed

+12
-12
lines changed

10 files changed

+12
-12
lines changed

analyzers/cmdi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func cmdInjectionRun(pass *analysis.Pass) (interface{}, error) {
7575
message := "Danger: possible command injection detected"
7676
targetFunc := util.GenerateTaintedCode(pass, vulnFunc.Fn, vulnFunc.Instr.Pos())
7777
taintSource := taintAnalyzer.TaintSource
78-
finding := util.MakeFinding(message, targetFunc, taintSource, "Command Injection")
78+
finding := util.MakeFinding(message, targetFunc, taintSource, "CWE-78: OS Command Injection")
7979
results = append(results, finding)
8080
}
8181
}

analyzers/cmdi_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestCommandInjection(t *testing.T) {
3939
}
4040
for i := 0; i < len(testFiles); i++ {
4141
t.Run(testFiles[i], func(t *testing.T) {
42-
testutil.RunTest(testFiles[i], testResults[i], "Command Injection", CommandInjectionAnalyzer, t)
42+
testutil.RunTest(testFiles[i], testResults[i], "CWE-78: OS Command Injection", CommandInjectionAnalyzer, t)
4343
})
4444
}
4545
}

analyzers/rsa.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ func rsaRun(pass *analysis.Pass) (interface{}, error) {
173173

174174
// Check if argument of vulnerable function has keylen that is less than RECOMMENDED_KEYLEN
175175
if keylen_check(pass, vulnFunc.Instr.Call.Args[1], call_graph) {
176-
message := fmt.Sprintf("Danger: key length is too short, recommend %d", RECOMMENDED_KEYLEN)
176+
message := fmt.Sprintf("Danger: RSA key length is too short, recommend %d", RECOMMENDED_KEYLEN)
177177
targetFunc := util.GenerateTaintedCode(pass, vulnFunc.Fn, vulnFunc.Instr.Pos())
178-
results = append(results, util.MakeFinding(message, targetFunc, nil, "RSA Key Length"))
178+
results = append(results, util.MakeFinding(message, targetFunc, nil, "CWE-326: Inadequate Encryption Strength"))
179179
}
180180
}
181181
}

analyzers/rsa_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestRsaKeylen(t *testing.T) {
5151
}
5252
for i := 0; i < len(testFiles); i++ {
5353
t.Run(testFiles[i], func(t *testing.T) {
54-
testutil.RunTest(testFiles[i], testResults[i], "RSA Key Length", RsaKeylenAnalyzer, t)
54+
testutil.RunTest(testFiles[i], testResults[i], "CWE-326: Inadequate Encryption Strength", RsaKeylenAnalyzer, t)
5555
})
5656
}
5757
}

analyzers/sqli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func sqlRun(pass *analysis.Pass) (interface{}, error) {
8080
message := "Danger: possible SQL injection detected"
8181
targetFunc := util.GenerateTaintedCode(pass, vulnFunc.Fn, vulnFunc.Instr.Pos())
8282
taintSource := taint_analyzer.TaintSource
83-
results = append(results, util.MakeFinding(message, targetFunc, taintSource, "SQL Injection"))
83+
results = append(results, util.MakeFinding(message, targetFunc, taintSource, "CWE-89: SQL Injection"))
8484
}
8585
}
8686
}

analyzers/sqli_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestSQLInjection(t *testing.T) {
3939
}
4040
for i := 0; i < len(testFiles); i++ {
4141
t.Run(testFiles[i], func(t *testing.T) {
42-
testutil.RunTest(testFiles[i], testResults[i], "SQL Injection", SQLInjectionAnalyzer, t)
42+
testutil.RunTest(testFiles[i], testResults[i], "CWE-89: SQL Injection", SQLInjectionAnalyzer, t)
4343
})
4444
}
4545
}

analyzers/ssrf.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func ssrfRun(pass *analysis.Pass) (interface{}, error) {
158158
message := "Danger: possible SSRF detected"
159159
targetFunc := util.GenerateTaintedCode(pass, vulnFunc.Fn, vulnFunc.Instr.Pos())
160160
taintSource := taintAnalyzer.TaintSource
161-
results = append(results, util.MakeFinding(message, targetFunc, taintSource, "SSRF"))
161+
results = append(results, util.MakeFinding(message, targetFunc, taintSource, "CWE-918: Server-Side Request Forgery"))
162162

163163
}
164164
}
@@ -169,7 +169,7 @@ func ssrfRun(pass *analysis.Pass) (interface{}, error) {
169169
message := "Danger: possible SSRF detected"
170170
targetFunc := util.GenerateTaintedCode(pass, vulnFunc.Fn, vulnFunc.Instr.Pos())
171171
taintSource := taintAnalyzer.TaintSource
172-
results = append(results, util.MakeFinding(message, targetFunc, taintSource, "SSRF"))
172+
results = append(results, util.MakeFinding(message, targetFunc, taintSource, "CWE-918: Server-Side Request Forgery"))
173173

174174
}
175175
}

analyzers/ssrf_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestSSRF(t *testing.T) {
4747
}
4848
for i := 0; i < len(testFiles); i++ {
4949
t.Run(testFiles[i], func(t *testing.T) {
50-
testutil.RunTest(testFiles[i], testResults[i], "SSRF", SSRFAnalyzer, t)
50+
testutil.RunTest(testFiles[i], testResults[i], "CWE-918: Server-Side Request Forgery", SSRFAnalyzer, t)
5151
})
5252
}
5353
}

analyzers/traversal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func traversalRun(pass *analysis.Pass) (interface{}, error) {
7575

7676
targetFunc := util.GenerateTaintedCode(pass, vulnFunc.Fn, vulnFunc.Instr.Pos())
7777
taintSource := taintAnalyzer.TaintSource
78-
results = append(results, util.MakeFinding(message, targetFunc, taintSource, "Path Traversal"))
78+
results = append(results, util.MakeFinding(message, targetFunc, taintSource, "CWE-22: Path Traversal"))
7979

8080
}
8181
}

analyzers/traversal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestPathTraversal(t *testing.T) {
5151
}
5252
for i := 0; i < len(testFiles); i++ {
5353
t.Run(testFiles[i], func(t *testing.T) {
54-
testutil.RunTest(testFiles[i], testResults[i], "Path Traversal", PathTraversalAnalyzer, t)
54+
testutil.RunTest(testFiles[i], testResults[i], "CWE-22: Path Traversal", PathTraversalAnalyzer, t)
5555
})
5656
}
5757
}

0 commit comments

Comments
 (0)