com.metaeffekt.artifact.enrichment.vulnerability.ghsa.GhsaEcosystem Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2021-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.metaeffekt.artifact.enrichment.vulnerability.ghsa;
import com.metaeffekt.artifact.enrichment.vulnerability.ghsa.matchers.*;
import com.metaeffekt.mirror.query.GhsaAdvisorIndexQuery;
/**
* All ecosystems provided by the
* GitHub Security Advisory API.
*/
public enum GhsaEcosystem {
MAVEN("Maven", "java", MavenGhsaMatcher.class),
NPM("npm", "javascript", NpmGhsaMatcher.class),
RUBY_GEMS("RubyGems", "ruby", RubyGemGhsaMatcher.class),
PY_PI("PyPI", "python", PythonPipGhsaMatcher.class),
PACKAGIST("Packagist", "php", NopGhsaMatcher.class),
GIT_HUB_ACTIONS("GitHub Actions", "github actions", NopGhsaMatcher.class),
PURL_TYPE_SWIFT("purl-type:swift", "swift", NopGhsaMatcher.class), // not searchable via web ui
GO("Go", "go", NopGhsaMatcher.class),
HEX("Hex", "erlang", HexGhsaMatcher.class),
CRATES_IO("crates.io", "rust", CratesIoGhsaMatcher.class),
PUB("Pub", "dart", NopGhsaMatcher.class),
NU_GET("NuGet", ".net", NuGetGhsaMatcher.class);
private final String name;
private final String programmingLanguage;
private final Class extends GhsaArtifactVulnerabilityMatcher> matcherClass;
GhsaEcosystem(String name, String programmingLanguage, Class extends GhsaArtifactVulnerabilityMatcher> matcherClass) {
this.name = name;
this.programmingLanguage = programmingLanguage;
this.matcherClass = matcherClass;
}
public String getName() {
return name;
}
public String getProgrammingLanguage() {
return programmingLanguage;
}
public Class extends GhsaArtifactVulnerabilityMatcher> getMatcherClass() {
return matcherClass;
}
public T createInstance(GhsaAdvisorIndexQuery query, Boolean githubReviewed) {
try {
return (T) matcherClass.getConstructor(GhsaAdvisorIndexQuery.class, Boolean.TYPE).newInstance(query, githubReviewed);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public static GhsaEcosystem fromName(String name) {
for (GhsaEcosystem ecosystem : values()) {
if (ecosystem.getName().equals(name)) {
return ecosystem;
}
}
throw new IllegalArgumentException("No " + GhsaEcosystem.class.getSimpleName() + " with name " + name);
}
@Override
public String toString() {
return name + " (" + programmingLanguage + ")";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy