@Override public final String toString() { final StringBuilder builder = new StringBuilder(); builder.append("[").append(this.getMvnGroup()).append("|").append(this.getArtifact()).append("|").append(this.getVersion()).append("]"); return builder.toString(); }
/** * Returns the path of the directory where the artifact is stored, relative to the local M2 repository. * E.g, com/jolira/guice/3.0.0. * @return */ @JsonIgnore private Path getRelM2Dir() { final StringBuilder b = new StringBuilder(); b.append(this.getLibId().getMvnGroup().replace('.', '/')).append("/"); b.append(this.getLibId().getArtifact()).append("/"); b.append(this.getLibId().getVersion()); return Paths.get(b.toString()); }
private boolean isAmongAggregatedModules(LibraryId _libid) { for(Application prj: this.modules) { if(prj.getMvnGroup().equals(_libid.getMvnGroup()) && prj.getArtifact().equals(_libid.getArtifact()) && prj.getVersion().equals(_libid.getVersion())) return true; } return false; }
/** * Compares this library ID with the provided library ID using, in that order, * group, artifact, or version. */ @Override public int compareTo(Object _other) { if(_other instanceof LibraryId) { final LibraryId other_libid = (LibraryId)_other; int result = this.getMvnGroup().compareToIgnoreCase(other_libid.getMvnGroup()); if(result==0) result = this.getArtifact().compareToIgnoreCase(other_libid.getArtifact()); if(result==0){ Version v = new Version(this.getVersion()); result = v.compareTo(new Version(other_libid.getVersion())); } return result; } else { throw new IllegalArgumentException("Expected object of type LibraryId, got [" + _other.getClass().getName() + "]"); } }
public synchronized String getVulnAst(LibraryId l){ if(this.lidVulnBytecodeAST.get(l)==null){ String ast_lid = BackendConnector.getInstance().getAstForQnameInLib(l.getMvnGroup()+"/"+l.getArtifact()+"/"+l.getVersion()+"/"+ type.toString()+"/"+construct,false,ProgrammingLanguage.JAVA); // the file is found if (ast_lid != null) { this.lidVulnBytecodeAST.put(l,ast_lid); } else { // the file is not found and cannot be used as a comparison basis, we set it to BytecodeNotFound to avoid furthur requests this.lidVulnBytecodeAST.put (l,BYTECODE_NOT_FOUND); } } String res = this.lidVulnBytecodeAST.get(l); if(res==BYTECODE_NOT_FOUND){ return null; } else { return res; } }
@Override public Path downloadArtifact(Artifact _doc) throws Exception { final String url = MAVEN_CENTRAL_REPO; final StringBuilder b = new StringBuilder(); b.append(url); b.append(_doc.getLibId().getMvnGroup().replace('.', '/')).append("/"); b.append(_doc.getLibId().getArtifact()).append("/"); b.append(_doc.getLibId().getVersion()).append("/"); b.append(_doc.getM2Filename()); // Make the query final RestTemplate rest_template = new RestTemplate(); Path result = null; try{ rest_template.execute(b.toString(), HttpMethod.GET, new DefaultRequestCallback(), new FileResponseExtractor(_doc, _doc.getAbsM2Path())); result = _doc.getAbsM2Path(); } catch(HttpClientErrorException e) { MavenCentralWrapper.log.error(_doc + " not available at [" +b.toString()+ "]"); } return result; }
public synchronized String getFixedAst(LibraryId l){ if(this.lidFixedBytecodeAST.get(l)==null){ String ast_lid = BackendConnector.getInstance().getAstForQnameInLib(l.getMvnGroup()+"/"+l.getArtifact()+"/"+l.getVersion()+"/"+ type.toString()+"/"+construct,false,ProgrammingLanguage.JAVA); // the file is found if (ast_lid != null) { this.lidFixedBytecodeAST.put(l,ast_lid); } else { // the file is not found and cannot be used as a comparison basis, we set it to BytecodeNotFound to avoid furthur requests this.lidFixedBytecodeAST.put (l,BYTECODE_NOT_FOUND); } } String res = this.lidFixedBytecodeAST.get(l); if(res==BYTECODE_NOT_FOUND){ return null; } else { return res; } }
/** * [OUT-OF-DATE] * Returns true if group, artifact, version are specified, * classifier is one of 'sources', 'javadoc', 'test-sources', and 'tests', and * packaging is one of 'pom', 'jar' and 'war'. * Without all this information, a download is not possible. * @param _doc * @return */ public boolean isReadyForDownload() { return this.getLibId().getMvnGroup()!=null && !this.getLibId().getMvnGroup().equals("") && this.getLibId().getArtifact()!=null && !this.getLibId().getArtifact().equals("") && this.getLibId().getVersion()!=null && !this.getLibId().getVersion().equals("") && (this.getClassifier()==null || this.getClassifier().equals("javadoc") || this.getClassifier().equals("sources") || this.getClassifier().equals("test-sources") || this.getClassifier().equals("tests") || this.getClassifier().equals("site")|| this.getClassifier().equals("jar")) && this.getPackaging()!=null && (this.getPackaging().equalsIgnoreCase("pom") || this.getPackaging().equalsIgnoreCase("jar") || this.getPackaging().equalsIgnoreCase("war") || this.getPackaging().equalsIgnoreCase("xml") || this.getPackaging().equalsIgnoreCase("sdist") || this.getPackaging().equalsIgnoreCase("bdist_wheel")); } }
def_ctx = this.getCompilationUnit(jid); log.debug("Determined compilation unit " + def_ctx + " for qname [" + qname + "]"); file = ClassDownloader.getInstance().getClass(doc.getLibId().getMvnGroup(), doc.getLibId().getArtifact(), doc.getLibId().getVersion(), def_ctx.getQualifiedName(), ClassDownloader.Format.JAVA);
log.info("Determined compilation unit " + def_ctx + " for qname [" + qname + "]"); file = ClassDownloader.getInstance().getClass(doc.getLibId().getMvnGroup(), doc.getLibId().getArtifact(), doc.getLibId().getVersion(), def_ctx.getQualifiedName(), ClassDownloader.Format.JAVA);
@Override public Path downloadArtifact(Artifact a) throws Exception { final Map<String,String> params = new HashMap<String,String>(); params.put("g", a.getLibId().getMvnGroup()); params.put("a", a.getLibId().getArtifact()); params.put("v", a.getLibId().getVersion());
for(LibraryId l: cpa.getLibsSameBytecode()){ JsonObject libraryId = new JsonObject(); libraryId.addProperty("group", l.getMvnGroup()); libraryId.addProperty("artifact", l.getArtifact()); libraryId.addProperty("version", l.getVersion());
@Override public int compareTo(Object _other) { if(_other instanceof Artifact) { final Artifact other_libid = (Artifact)_other; int result = this.getLibId().getMvnGroup().compareToIgnoreCase(other_libid.getLibId().getMvnGroup()); if(result==0) result = this.getLibId().getArtifact().compareToIgnoreCase(other_libid.getLibId().getArtifact()); if(result==0 && this.getTimestamp()!=null && other_libid.getTimestamp()!=null) result = this.getTimestamp().compareTo(other_libid.getTimestamp()); if(result==0){ Version v = new Version(this.getLibId().getVersion()); result = v.compareTo(new Version(other_libid.getLibId().getVersion())); } // result = this.getLibId().getVersion().compareToIgnoreCase(((Artifact) _other).getLibId().getVersion()); return result; } else { throw new IllegalArgumentException("Expected object of type Artifact, got [" + _other.getClass().getName() + "]"); } }
@Override public Set<Artifact> getGreaterArtifactVersions(String group, String artifact, String greaterThanVersion, String classifier, String packaging) throws Exception { Set<Artifact> all = this.getAllArtifactVersions(group, artifact, classifier, packaging); Set<Artifact> allWithTimestamp = new TreeSet<Artifact>(); Artifact toCompare = null; for(Artifact a : all){ if(a.getLibId().getVersion().equals(greaterThanVersion)) toCompare = this.getArtifactVersion(a.getLibId().getMvnGroup(), a.getLibId().getArtifact(), a.getLibId().getVersion(), null, null, null); else allWithTimestamp.add(this.getArtifactVersion(a.getLibId().getMvnGroup(), a.getLibId().getArtifact(), a.getLibId().getVersion(), null, null, null)); } // Return bad request if version is not found if(toCompare==null){ log.error("Version [" + greaterThanVersion + "] not found in Nexus for group [" + group + "] and artifact [" + artifact + "]"); return null; } Set<Artifact> greater = new TreeSet<Artifact>(); for (Artifact t: allWithTimestamp){ if (t.compareTo(toCompare)>0) greater.add(t); } return greater; }
if(b.getMvnGroup().equals(a.getMvnGroup()) && b.getArtifact().equals(a.getArtifact())&&b.getVersion().equals(a.getVersion())){ if(!secureOnly){ result.add(b);
sb.append(cpr.getQname()).append(COMMA_DELIMITER); sb.append(getShortRepoPathName(cpr.getPath())).append(COMMA_DELIMITER); sb.append(cpr.getLidResult().getLibId().getMvnGroup()).append(COMMA_DELIMITER); sb.append(cpr.getLidResult().getLibId().getArtifact()).append(COMMA_DELIMITER); sb.append(cpr.getLidResult().getLibId().getVersion()).append(COMMA_DELIMITER);
List<com.sap.psr.vulas.shared.json.model.ConstructId> other_pack = ServiceWrapper.getInstance().getArtifactConstructs(lid.getMvnGroup(),lid.getArtifact(),lid.getVersion(),ConstructType.PACK); sw.lap("Packs for "+lid.toString()+"received from cia ",true); List<com.sap.psr.vulas.shared.json.model.ConstructId> other = ServiceWrapper.getInstance().getArtifactConstructs(lid.getMvnGroup(),lid.getArtifact(),lid.getVersion(),null);
} else if (!libId.getArtifact().equals(other.getLibId().getArtifact())) return false; if (libId.getMvnGroup() == null) { if (other.getLibId().getMvnGroup() != null) return false; } else if (!libId.getMvnGroup().equals(other.getLibId().getMvnGroup())) return false; if (libId.getVersion() == null) {
protected void doProcessing() throws Exception { // Old JAR PackageMapper oldPackages = new PackageMapper(); ClassfileLoader oldJar = new AggregatingClassfileLoader(); oldJar.addLoadListener(oldPackages); List<String> old_files = new ArrayList<String>(); old_files.add(this.oldPath.toString()); oldJar.load(old_files); // New JAR PackageMapper newPackages = new PackageMapper(); ClassfileLoader newJar = new AggregatingClassfileLoader(); newJar.addLoadListener(newPackages); List<String> new_files = new ArrayList<String>(); new_files.add(this.newPath.toString()); newJar.load(new_files); String name = this.oldLib.getLibId().getMvnGroup() + ":" + this.oldLib.getLibId().getArtifact(); String oldLabel = name + ":" + oldLib.getLibId().getVersion(); String newLabel = name + ":" + newLib.getLibId().getVersion(); Differences differences = getDifferencesFactory().createProjectDifferences(name, oldLabel, oldPackages, newLabel, newPackages); //Report report = new Report(getCommandLine().getSingleSwitch("encoding"), getCommandLine().getSingleSwitch("dtd-prefix")); visitor = new JarDiffVisitor(this.oldLib, this.newLib); differences.accept(visitor); }
if( (a.getLibraryId()!=null && l.getLibraryId()==null && a.getLibraryId().getMvnGroup().equals("org.apache.tomcat") && a.getLibraryId().getVersion().equals(version)) || && a.getLibraryId().getMvnGroup().equals("org.apache.tomcat") && a.getLibraryId().getArtifact().startsWith("tomcat-") && l.getLibraryId().getMvnGroup().equals("p2.eclipse-plugin") && l.getLibraryId().getArtifact().substring(0,l.getLibraryId().getArtifact().lastIndexOf(".")).equals("org.apache") && l.getLibraryId().getArtifact().substring(l.getLibraryId().getArtifact().lastIndexOf(".")+1, l.getLibraryId().getArtifact().length()).equals(a.getLibraryId().getArtifact().substring(a.getLibraryId().getArtifact().lastIndexOf("-")+1,a.getLibraryId().getArtifact().length()))