diff --git a/internal/services/engines/dart/rules.go b/internal/services/engines/dart/rules.go
index 9831e7e53..cb63c921e 100644
--- a/internal/services/engines/dart/rules.go
+++ b/internal/services/engines/dart/rules.go
@@ -160,9 +160,9 @@ func NewNoLogSensitive() text.TextRule {
},
Type: text.Regular,
Expressions: []*regexp.Regexp{
- regexp.MustCompile(`print\(.*\$`),
- regexp.MustCompile(`window\.console.*\(`),
- regexp.MustCompile(`log.*\.(finest|finer|fine|config|info|warning|severe|shout|erro).*\(`),
+ regexp.MustCompile(`print\(.*(\$|%|('|")\s*\+)`),
+ regexp.MustCompile(`window\.console.*\(.*(\$|%|('|")\s*\+)`),
+ regexp.MustCompile(`log.*\.(finest|finer|fine|config|info|warning|severe|shout|erro).*\(.*(\$|%|('|")\s*\+)`),
},
}
}
@@ -278,10 +278,10 @@ func NewNoUseCipherMode() text.TextRule {
},
Type: text.Regular,
Expressions: []*regexp.Regexp{
- regexp.MustCompile(`(?i)AesMode\.ECB`),
- regexp.MustCompile(`(?i)AesMode\.OFB`),
- regexp.MustCompile(`(?i)AesMode\.CTS`),
- regexp.MustCompile(`(?i)AesMode\.CFB`),
+ regexp.MustCompile(`(?i)(AesMode\.ECB)`),
+ regexp.MustCompile(`(?i)(AesMode\.OFB)`),
+ regexp.MustCompile(`(?i)(AesMode\.CTS)`),
+ regexp.MustCompile(`(?i)(AesMode\.CFB)`),
},
}
}
diff --git a/internal/services/engines/dart/rules_test.go b/internal/services/engines/dart/rules_test.go
index 1f72f1047..5695e27af 100644
--- a/internal/services/engines/dart/rules_test.go
+++ b/internal/services/engines/dart/rules_test.go
@@ -107,6 +107,167 @@ func TestRulesVulnerableCode(t *testing.T) {
},
},
},
+ {
+ Name: "HS-DART-7",
+ Rule: NewXSSAttack(),
+ Src: SampleVulnerableXSSAttack,
+ Findings: []engine.Finding{
+ {
+ CodeSample: "var element = new Element.html(sprintf(\"
%s
\", [content]));",
+ SourceLocation: engine.Location{
+ Line: 8,
+ Column: 19,
+ },
+ },
+ },
+ },
+ {
+ Name: "HS-DART-8",
+ Rule: NewNoLogSensitive(),
+ Src: SampleVulnerableNoLogSensitive,
+ Findings: []engine.Finding{
+ {
+ CodeSample: "print(sprintf(\"User identity is: %s\", [identity]));",
+ SourceLocation: engine.Location{
+ Line: 9,
+ Column: 1,
+ },
+ },
+ {
+ CodeSample: "_logger.info(sprintf(\"User identity is: %s\", [identity]));",
+ SourceLocation: engine.Location{
+ Line: 11,
+ Column: 2,
+ },
+ },
+ },
+ },
+ {
+ Name: "HS-DART-9",
+ Rule: NewWeakHashingFunctionMd5OrSha1(),
+ Src: SampleVulnerableWeakHashingFunctionMd5OrSha1,
+ Findings: []engine.Finding{
+ {
+ CodeSample: "var digest = md5.convert(content);",
+ SourceLocation: engine.Location{
+ Line: 11,
+ Column: 15,
+ },
+ },
+ },
+ },
+ {
+ Name: "HS-DART-10",
+ Rule: NewNoUseSelfSignedCertificate(),
+ Src: SampleVulnerableNoUseSelfSignedCertificate,
+ Findings: []engine.Finding{
+ {
+ CodeSample: "context.setTrustedCertificates(\"client.cer\");",
+ SourceLocation: engine.Location{
+ Line: 4,
+ Column: 8,
+ },
+ },
+ },
+ },
+ {
+ Name: "HS-DART-11",
+ Rule: NewNoUseBiometricsTypeAndroid(),
+ Src: SampleVulnerableNoUseBiometricsTypeAndroid,
+ Findings: []engine.Finding{
+ {
+ CodeSample: "authenticated = await auth.authenticateWithBiometrics(",
+ SourceLocation: engine.Location{
+ Line: 4,
+ Column: 29,
+ },
+ },
+ },
+ },
+ {
+ Name: "HS-DART-12",
+ Rule: NewNoListClipboardChanges(),
+ Src: SampleVulnerableNoListClipboardChanges,
+ Findings: []engine.Finding{
+ {
+ CodeSample: "Map result = await SystemChannels.platform.invokeMethod('Clipboard.getData');",
+ SourceLocation: engine.Location{
+ Line: 4,
+ Column: 75,
+ },
+ },
+ },
+ },
+ {
+ Name: "HS-DART-13",
+ Rule: NewSQLInjection(),
+ Src: SampleVulnerableSQLInjection,
+ Findings: []engine.Finding{
+ {
+ CodeSample: "List