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 {
381381 * be the string contents of that tag.
382382 */
383383 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+ }
384393}
385394
386395/**
Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ import java
1717import semmle.code.xml.MavenPom
1818
1919predicate isInsecureRepositoryUsage ( DeclaredRepository repository ) {
20- repository .getRepositoryUrl ( ) .regexpMatch ( "(?i)^(http|ftp)://(?!localhost[:/]).*" )
20+ repository .getRepositoryUrl ( ) .regexpMatch ( "(?i)^(http|ftp)://(?!localhost[:/]).*" ) and
21+ not repository .isDisabled ( )
2122}
2223
2324from DeclaredRepository repository
Original file line number Diff line number Diff line change 6161 <!-- GOOD! Use HTTPS -->
6262 <url >https://insecure-repository.example</url >
6363 </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 >
6476 </pluginRepositories >
6577</project >
You can’t perform that action at this time.
0 commit comments