mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
Handle disabled Maven repositories
This commit is contained in:
@@ -381,6 +381,15 @@ class DeclaredRepository extends PomElement {
|
|||||||
* be the string contents of that tag.
|
* be the string contents of that tag.
|
||||||
*/
|
*/
|
||||||
string getRepositoryUrl() { result = this.getAChild("url").(PomElement).getValue() }
|
string getRepositoryUrl() { result = this.getAChild("url").(PomElement).getValue() }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds if this repository is disabled in both the `releases` and `snapshots` policies.
|
||||||
|
*/
|
||||||
|
predicate isDisabled() {
|
||||||
|
forex(PomElement policy | policy = this.getAChild(["releases", "snapshots"]) |
|
||||||
|
policy.getAChild("enabled").(PomElement).getValue() = "false"
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ import java
|
|||||||
import semmle.code.xml.MavenPom
|
import semmle.code.xml.MavenPom
|
||||||
|
|
||||||
predicate isInsecureRepositoryUsage(DeclaredRepository repository) {
|
predicate isInsecureRepositoryUsage(DeclaredRepository repository) {
|
||||||
repository.getRepositoryUrl().regexpMatch("(?i)^(http|ftp)://(?!localhost[:/]).*")
|
repository.getRepositoryUrl().regexpMatch("(?i)^(http|ftp)://(?!localhost[:/]).*") and
|
||||||
|
not repository.isDisabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
from DeclaredRepository repository
|
from DeclaredRepository repository
|
||||||
|
|||||||
@@ -61,5 +61,17 @@
|
|||||||
<!-- GOOD! Use HTTPS -->
|
<!-- GOOD! Use HTTPS -->
|
||||||
<url>https://insecure-repository.example</url>
|
<url>https://insecure-repository.example</url>
|
||||||
</pluginRepository>
|
</pluginRepository>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>disabled-repo</id>
|
||||||
|
<name>Disabled Repository</name>
|
||||||
|
<releases>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
<!-- GOOD! Disabled repo -->
|
||||||
|
<url>http://insecure-repository.example</url>
|
||||||
|
</pluginRepository>
|
||||||
</pluginRepositories>
|
</pluginRepositories>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Reference in New Issue
Block a user