@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(); }
public com.sap.psr.vulas.shared.json.model.LibraryId toSharedType() { return new com.sap.psr.vulas.shared.json.model.LibraryId(this.mvnGroup, this.artifact, this.version); } }
@Override public String toString(){ StringBuilder sb = new StringBuilder(); sb.append("Name: ").append(this.libId.toString()).append(" -> "); sb.append("QnameInJar: ").append(qnameInJar) .append("; sourcesAvailable: ").append(sourcesAvailable); return sb.toString(); }
/** * Returns the artifact's filename root, e.g., guice-3.0.0 * To be completed with one of the available postfix in this.ec * @return */ @JsonIgnore public String getM2Filename() { final StringBuilder b = new StringBuilder(); b.append(this.getLibId().getArtifact()).append("-").append(this.getLibId().getVersion()); if(this.classifier!=null && !this.classifier.equals("")) b.append("-").append(this.getClassifier()); if(this.lang!=null && this.lang==ProgrammingLanguage.PY){ if (this.getPackaging().equals("sdist")){ b.append(".tar.gz"); } else if (this.getPackaging().equals("bdist_wheel")){ b.append(".whl"); } } else { b.append(".").append(this.getPackaging()); } return b.toString(); }
String key = l.getLibraryId().getMvnGroup()+":"+l.getLibraryId().getArtifact(); if ( !groupsArtifactsToCheck.containsKey(key) ){ groupsArtifactsToCheck.put(key, l.getLibraryId()); for(Entry<String, LibraryId> e : groupsArtifactsToCheck.entrySet()){ LibraryId value = (LibraryId)e.getValue(); if(( !excl_gavs.contains(value.getMvnGroup()+":"+value.getArtifact()+":"+value.getVersion())) && ( !excl_gas.contains(value.getMvnGroup()+":"+value.getArtifact())) && ( !excl_gs.contains(value.getMvnGroup())) ){ groupsArtifactsToCheck_filtered.put(e.getKey(),e.getValue()); log.info("Blacklisted library: Remove [" + value.toString() + "] from libraries to be checked"); Artifact[] artifactsLibraries = BackendConnector.getInstance().getAllArtifactsGroupArtifact(value.getMvnGroup(), value.getArtifact()); boolean found = false; if ( artifactsLibraries != null ){ if(al.getLibId().equals(value)) found=true; if ( !finalLibrariesList.contains(al) ){ log.info("Library Id [" + value.toString() +"] not found during search in Maven, Nexus, Pypi"); Artifact a = new Artifact(value.getMvnGroup(), value.getArtifact(), value.getVersion()); if(!finalLibrariesList.contains(a)) finalLibrariesList.add(a); for(Artifact a : finalLibrariesList){ LibraryId lid = a.getLibId();
/** * Filter the given packages according to whether the artifact name is (or is not, depending on the boolean flag) contained in the given filter. * @param _packages * @param _filter * @param _include * @return */ public static Set<PipInstalledPackage> filterUsingArtifact(Set<PipInstalledPackage> _packages, StringList _filter, boolean _include) { final Set<PipInstalledPackage> r = new HashSet<PipInstalledPackage>(); for(PipInstalledPackage p: _packages) { try { if(_include) { if(_filter.contains(p.getLibrary().getLibraryId().getArtifact())) r.add(p); } else { if(!_filter.contains(p.getLibrary().getLibraryId().getArtifact())) r.add(p); } } catch (FileAnalysisException e) { log.error("Error getting library ID of package [" + p + "]: " + e.getMessage(), e); } } return r; }
@Override public Set<Artifact> getGreaterArtifactVersions(String group, String artifact, String greaterThanVersion, String classifier, String packaging) throws Exception { Set<Artifact> all = this.getAllArtifactVersions(group, artifact, null, null); Artifact toCompare=null; Set<Artifact> greater = new TreeSet<Artifact>(); for(Artifact a : all){ if(a.getLibId().getVersion().equals(greaterThanVersion)){ toCompare=a; break; } } // Return bad request if version is not found if(toCompare==null){ log.error("Version [" + greaterThanVersion + "] not found in Pypi for group [" + group + "] and artifact [" + artifact + "]"); return null; } for (Artifact t: all){ if (t.compareTo(toCompare)>0) greater.add(t); } return greater; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; AffectedLibrary other = (AffectedLibrary) obj; if (bugId == null) { if (other.bugId != null) return false; } else if (!bugId.equals(other.bugId)) return false; if (libraryId == null) { if (other.libraryId != null) return false; } else if (!libraryId.equals(other.libraryId)) return false; return true; }
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); LibraryController.log.info("["+lid.toString()+"] has ["+other_pack.size()+"] packages instead of [" + pack_cids.size()+ "]"); continue; if(!pack_cids.contains(new ConstructId(c.getLang(),c.getType(),c.getQname()))){ equal = false; LibraryController.log.info("["+lid.toString()+"] contains a pack not included in the requested jar: " + c.toString()); break; List<com.sap.psr.vulas.shared.json.model.ConstructId> other = ServiceWrapper.getInstance().getArtifactConstructs(lid.getMvnGroup(),lid.getArtifact(),lid.getVersion(),null); sw.lap("All constructs for ["+lid.toString()+"] received from cia ",true); if(!(other.size()==cids.size())){ LibraryController.log.info("Size of constructs of ["+lid.toString()+"] is: "+other.size()); continue; if(!cids.contains(new ConstructId(c.getLang(),c.getType(),c.getQname()))){ equal = false; LibraryController.log.info("["+lid.toString()+"] contains a construct not included in the requested jar: " + c.toString()); break; LibraryController.log.info("["+lid.toString()+"] is equal"); results.add(lid);
final Path old_jar = r.downloadArtifact(artifacts[0]); final Path new_jar = r.downloadArtifact(artifacts[1]); final String label = artifacts[0].getLibId().getArtifact() + "-" + artifacts[0].getLibId().getVersion() + "--" + artifacts[1].getLibId().getArtifact() + "-" + artifacts[1].getLibId().getVersion(); final File diff_xml = File.createTempFile(label + "-", ".xml");
if(o.getLibId().equals(l.getLibId())){ found=true; break;
/** * 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()); }
log.info("Analysis of lib ["+ l.toString() + "] with tid [" +tid+"]"); binAvailable = BackendConnector.getInstance().doesArtifactExist(l.getMvnGroup(), l.getArtifact(), l.getVersion(), false, (lang==ProgrammingLanguage.JAVA)?"jar":"sdist"); if(!binAvailable){ log.warn("No artifact available for library Id [" + l.toString() +"], it will not be included in the csv"); sourcesAvailable = BackendConnector.getInstance().doesArtifactExist(l.getMvnGroup(), l.getArtifact(), l.getVersion(), true, "jar"); int changesToF = -1; String qString = l.getMvnGroup()+"/"+l.getArtifact()+"/"+l.getVersion(); cids_array=BackendConnector.getInstance().getArtifactBugConstructsIntersection(qString,c,(lang==ProgrammingLanguage.JAVA)?"jar":"sdist"); if(cids_array ==null){ log.warn("The intersection returned null (thus something went wrong in cia); the Jar for library Id [" + l.toString() +"] will not be included in the csv for MOD constructs"); } else { cids = Arrays.asList(cids_array); log.info("JAVA Qname ["+mcCC.getConstructId().getQname()+"] not in sources of [" + l.toString()+"]"); ConstructId[] adcids_array = BackendConnector.getInstance().getArtifactBugConstructsIntersection(qString,ad,(lang==ProgrammingLanguage.JAVA)?"jar":"sdist"); if(adcids_array ==null){ log.warn("The intersection returned null (thus something went wrong in cia); the artifact for library Id [" + l.toString() +"] will not be included in the csv for ADD/DEL constructs"); } else { log.info("++++++++" + "Thread " + (tid) + " for library id " + libId.toString() +" finished+++++++++"); return results;
Path result = null; try{ final PypiResponse response = this.searchInPypi(a.getLibId().getArtifact(),a.getLibId().getVersion()); if(k.equals(a.getLibId().getVersion())){ for(PypiRelease release : response.getReleases().get(k)){ if(release.getPackagetype().equals(a.getPackaging())){
public Artifact(String _g,String _a,String _v) { super(); libId = new LibraryId(_g,_a,_v); }
@Override public String toString() { final StringBuilder b = new StringBuilder(); b.append("[").append(libId.toString()); if(this.classifier!=null && !this.classifier.equals("")) b.append(":").append(this.getClassifier()); if(this.packaging!=null && !this.packaging.equals("")) b.append(":").append(packaging); b.append(":"+this.getTimestamp()).append("]"); return b.toString(); }
if(a.getLibraryId().equals(dep.getLib().getLibraryId())) {
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; }
public void setLibsSameBytecodeAsString(String[] libsSameBytecode) { if (this.libsSameBytecode == null) this.libsSameBytecode= new ArrayList<LibraryId>(); for(int i=0;i<libsSameBytecode.length;i++){ String[] l = libsSameBytecode[i].split(":"); this.libsSameBytecode.add(new LibraryId(l[0],l[1],l[2])); } }
public String toString() { final StringBuilder b = new StringBuilder(); final String classname = this.getClass().getName().substring(1 + this.getClass().getName().lastIndexOf(".")); b.append(classname + "[jar/war=").append(this.jarWriter.getOriginalJarFileName()); b.append(", libId=").append( (this.libraryId==null?"false":this.libraryId.toString())); b.append(", instr=").append(this.instrument); b.append(", instrCtx=").append( (JarAnalyzer.getAppContext()==null?"false":JarAnalyzer.getAppContext().toString(false)) ).append("]"); return b.toString(); }