Skip to content

Instantly share code, notes, and snippets.

@jonesbusy
Created November 25, 2020 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonesbusy/9f0da1bc257eab9ae8f07c18b764e9ac to your computer and use it in GitHub Desktop.
Save jonesbusy/9f0da1bc257eab9ae8f07c18b764e9ac to your computer and use it in GitHub Desktop.
Check if a Jenkins plugin or its dependencies are vulnerable
def static isPluginVulnerable(name) {
def plugins = [:]
// Push all plugins from all update site
jenkins.model.Jenkins.instance.updateCenter.sites.each {plugins += it.data.plugins}
def plugin = plugins[name]
// Ignore
if (!plugin) {
println("Plugin '${name}' doesn't exists. Nothing to do.")
return false
}
// Any warning
if (plugin.warnings) {
return true
}
// Let's be recursive, we should not have any circular dependencies
def vulnerable = false
plugin.dependencies.each { dependencyName, dependencyVersion ->
if (isPluginVulnerable(dependencyName)) {
vulnerable = true
}
}
return vulnerable
}
// Examples
println isPluginVulnerable('git')
println isPluginVulnerable('envinject')
println isPluginVulnerable('jenkins-multijob-plugin')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment