com.metaeffekt.mirror.contents.vulnerability.VulnerableSoftwareVersionRangeCpe 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.mirror.contents.vulnerability;
import com.metaeffekt.artifact.analysis.version.Version;
import com.metaeffekt.artifact.analysis.version.curation.VersionContext;
import com.metaeffekt.artifact.analysis.vulnerability.CommonEnumerationUtil;
import org.json.JSONObject;
import us.springett.parsers.cpe.Cpe;
public class VulnerableSoftwareVersionRangeCpe extends VulnerableSoftwareVersionRange {
private final Cpe cpe;
public VulnerableSoftwareVersionRangeCpe(Cpe cpe, String versionStartExcluding, String versionStartIncluding, String versionEndIncluding, String versionEndExcluding, VersionContext context, boolean vulnerable) {
super(cpe.getVersion(), cpe.getUpdate(), versionStartExcluding, versionStartIncluding, versionEndIncluding, versionEndExcluding, context, vulnerable);
this.cpe = cpe;
}
public Cpe getCpe() {
return cpe;
}
public boolean matches(Cpe cpe) {
if (!CommonEnumerationUtil.compareCpeUsingWildcardsIgnoreVersionUpdate(cpe, this.cpe)) {
return false;
}
return super.matches(Version.of(cpe.getVersion(), cpe.getUpdate(), VersionContext.fromCpe(cpe)));
}
@Override
public JSONObject toJson() {
return super.toJson()
.put("criteria", CommonEnumerationUtil.toCpe22UriOrFallbackToCpe23FS(this.cpe));
}
@Override
public String toString() {
return CommonEnumerationUtil.toCpe22UriOrFallbackToCpe23FS(this.cpe) + " " + super.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy