File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
test/query-tests/security/CWE-829/semmle/tests Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -381,6 +381,15 @@ class DeclaredRepository extends PomElement {
381
381
* be the string contents of that tag.
382
382
*/
383
383
string getRepositoryUrl ( ) { result = this .getAChild ( "url" ) .( PomElement ) .getValue ( ) }
384
+
385
+ /**
386
+ * Holds if this repository is disabled in both the `releases` and `snapshots` policies.
387
+ */
388
+ predicate isDisabled ( ) {
389
+ forex ( PomElement policy | policy = this .getAChild ( [ "releases" , "snapshots" ] ) |
390
+ policy .getAChild ( "enabled" ) .( PomElement ) .getValue ( ) = "false"
391
+ )
392
+ }
384
393
}
385
394
386
395
/**
Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ import java
17
17
import semmle.code.xml.MavenPom
18
18
19
19
predicate isInsecureRepositoryUsage ( DeclaredRepository repository ) {
20
- repository .getRepositoryUrl ( ) .regexpMatch ( "(?i)^(http|ftp)://(?!localhost[:/]).*" )
20
+ repository .getRepositoryUrl ( ) .regexpMatch ( "(?i)^(http|ftp)://(?!localhost[:/]).*" ) and
21
+ not repository .isDisabled ( )
21
22
}
22
23
23
24
from DeclaredRepository repository
Original file line number Diff line number Diff line change 61
61
<!-- GOOD! Use HTTPS -->
62
62
<url >https://insecure-repository.example</url >
63
63
</pluginRepository >
64
+ <pluginRepository >
65
+ <id >disabled-repo</id >
66
+ <name >Disabled Repository</name >
67
+ <releases >
68
+ <enabled >false</enabled >
69
+ </releases >
70
+ <snapshots >
71
+ <enabled >false</enabled >
72
+ </snapshots >
73
+ <!-- GOOD! Disabled repo -->
74
+ <url >http://insecure-repository.example</url >
75
+ </pluginRepository >
64
76
</pluginRepositories >
65
77
</project >
You can’t perform that action at this time.
0 commit comments