SortedBugCollection origCollection = new SortedBugCollection(); origCollection.readXML(System.in); } else { origCollection.readXML(args[argCount++]); SortedBugCollection resultCollection = origCollection.createEmptyCollectionWithMetadata(); Project project = resultCollection.getProject(); int passed = 0; int dropped = 0; resultCollection.setWithMessages(commandLine.withMessages); if (commandLine.hashChangedSpecified) { origCollection.computeBugHashes(); ProjectStats projectStats = resultCollection.getProjectStats(); projectStats.clearBugCounts(); if (commandLine.classPattern != null) { for (Iterator<AppVersion> i = origCollection.appVersionIterator(); i.hasNext();) { AppVersion v = i.next(); versions.put(v.getReleaseName(), v); AppVersion v = resultCollection.getCurrentAppVersion(); versions.put(v.getReleaseName(), v); timeStamps.put(v.getTimestamp(), v); if (trimToVersion < origCollection.getSequenceNumber()) { String name = resultCollection.getAppVersionFromSequenceNumber(trimToVersion).getReleaseName(); long timestamp = resultCollection.getAppVersionFromSequenceNumber(trimToVersion).getTimestamp();
@Override public void writePrologue(XMLOutput xmlOutput) throws IOException { xmlOutput.beginDocument(); xmlOutput.openTag( ROOT_ELEMENT_NAME, new XMLAttributeList().addAttribute("version", analysisVersion) .addAttribute("sequence", String.valueOf(getSequenceNumber())) .addAttribute("timestamp", String.valueOf(getTimestamp())) .addAttribute("analysisTimestamp", String.valueOf(getAnalysisTimestamp())) .addAttribute("release", getReleaseName())); project.writeXML(xmlOutput, null, this); }
static public void merge(HashSet<String> hashes, SortedBugCollection into, SortedBugCollection from) { for (BugInstance bugInstance : from.getCollection()) { if (hashes == null || hashes.add(bugInstance.getInstanceHash())) { into.add(bugInstance); } } ProjectStats stats = into.getProjectStats(); ProjectStats stats2 = from.getProjectStats(); stats.addStats(stats2); Project project = into.getProject(); Project project2 = from.getProject(); project.add(project2); for(AnalysisError error : from.getErrors()) { into.addError(error); } return; }
public NewResults(String origFilename, String newFilename) throws IOException, DocumentException { this(new SortedBugCollection(), new SortedBugCollection()); origCollection.readXML(origFilename); newCollection.readXML(newFilename); }
public SortedBugCollection execute() { SortedBugCollection result = new SortedBugCollection(); for (Iterator<BugInstance> i = newCollection.iterator(); i.hasNext();) { BugInstance bugInstance = i.next(); if (!origCollection.contains(bugInstance)) { result.add(bugInstance); } } return result; }
public void readXML(URL u) throws IOException, DocumentException { InputStream in = progessMonitoredInputStream(u.openConnection(), "Loading analysis"); dataSource = u.toString(); try { readXML(in); } catch (IOException e) { throw newIOException(u, e); } catch (DocumentException e) { throw new DocumentException("Failing reading " + u, e); } }
SortedBugCollection origCollection = new SortedBugCollection(); origCollection.readXML(args[argCount++]); } else { origCollection.readXML(System.in); Project project = origCollection.getProject(); origCollection.setReleaseName(commandLine.revisionName); origCollection.getProject().setProjectName(commandLine.projectName); origCollection.setTimestamp(commandLine.revisionTimestamp); origCollection.setWithMessages(commandLine.withMessages); origCollection.getProjectStats().getPackageStats().clear(); for (PackageStats ps : origCollection.getProjectStats().getPackageStats()) { ps.getClassStats().clear(); origCollection.clearMissingClasses(); if (last < origCollection.getSequenceNumber()) { String name = origCollection.getAppVersionFromSequenceNumber(last).getReleaseName(); long timestamp = origCollection.getAppVersionFromSequenceNumber(last).getTimestamp(); origCollection.setReleaseName(name); origCollection.setTimestamp(timestamp); origCollection.trimAppVersions(last);
SortedBugCollection bugCollection = new SortedBugCollection(); if (argCount < args.length) { bugCollection.readXML(args[argCount++]); } else { bugCollection.readXML(System.in); SortedBugCollection results = bugCollection.createEmptyCollectionWithMetadata(); Project project = results.getProject(); project.getSourceDirList().clear(); project.getFileList().clear(); project.getAuxClasspathEntryList().clear(); results.getProjectStats().getPackageStats().clear(); results.clearMissingClasses(); results.clearErrors(); results.add(Obfuscate.obfuscate(bug), false); results.writeXML(System.out); } else { results.writeXML(args[argCount++]);
public final void reportBugsFromXml(@WillClose InputStream in, Project theProject) throws IOException, DocumentException { SortedBugCollection theCollection = new SortedBugCollection(theProject); theCollection.readXML(in); for (BugInstance bug : theCollection.getCollection()) { doReportBug(bug); } }
public CopyBuggySource(String[] args) throws Exception { origCollection = new SortedBugCollection(); origCollection.readXML(args[0]); project = origCollection.getProject(); sourceFinder = new SourceFinder(project); src = new File(args[1]); kind = SrcKind.get(src); switch (kind) { case DIR: break; case ZIP: zOut = new ZipOutputStream(new FileOutputStream(src)); break; case Z0P_GZ: zOut = new ZipOutputStream(new DeflaterOutputStream(new FileOutputStream(src))); zOut.setLevel(0); break; } }
SortedBugCollection bugCollection = new SortedBugCollection(); if (argCount < args.length) { bugCollection.readXML(args[argCount++]); } else { bugCollection.readXML(System.in); for (int i = 0; i <= bugCollection.getSequenceNumber(); i++) { live.add(new Bag<String>()); died.add(new Bag<String>()); int finish = buried; if (finish == 0) { finish = (int) bugCollection.getSequenceNumber(); for (int i = 0; i < bugCollection.getSequenceNumber(); i++) { for (Map.Entry<String, Integer> e : died.get(i).entrySet()) { Integer buried = e.getValue(); SortedBugCollection results = bugCollection.createEmptyCollectionWithMetadata(); for (BugInstance b : bugCollection) { int buried = (int) b.getLastVersion() + 1; int survied = live.get((int) bugCollection.getSequenceNumber()).getCount(bugPattern); if (survied == 0 && allBugs.getCount(bugPattern) > 100) { continue; results.add(b, false); results.writeXML(System.out);
SortedBugCollection more = new SortedBugCollection(); more.readXML(argv[i]); if (results == null) { results = more.createEmptyCollectionWithMetadata(); return; results.setWithMessages(commandLine.withMessages); if (commandLine.outputFile == null) { results.writeXML(System.out); } else { results.writeXML(commandLine.outputFile);
private static void listVersion(PrintWriter out, @CheckForNull String fileName, boolean formatDates) throws IOException, DocumentException { SortedBugCollection origCollection; origCollection = new SortedBugCollection(); origCollection.readXML(System.in); } else { origCollection.readXML(fileName); AppVersion appVersion = origCollection.getCurrentAppVersion(); ProjectStats stats = origCollection.getProjectStats(); out.print(appVersion.getReleaseName()); out.print('\t'); out.print(appVersion.getCodeSize()); out.print('\t'); out.print(origCollection.getErrors().size()); out.print('\t'); out.print(stats.getTotalBugs());
SortedBugCollection bugCollection = new SortedBugCollection(commandLine.getProject()); if (argCount < args.length) { bugCollection.readXML(args[argCount++]); } else { bugCollection.readXML(System.in); RuntimeException storedException = null; if (commandLine.annotationUploadFormat) { bugCollection.computeBugHashes(); for (Iterator<BugInstance> i = bugCollection.iterator(); i.hasNext();) { BugInstance warning = i.next(); try { for (BugInstance warning : bugCollection.getCollection()) { if (!reporter.isApplySuppressions() || !bugCollection.getProject().getSuppressionFilter().match(warning)) { int rank = warning.getBugRank(); BugPattern pattern = warning.getBugPattern();
cliUiCallback); more.readXML(analysisFile); BugRanker.trimToMaxRank(more, options.maxConsideredRank); if (results != null) { results.getProject().setCloudId(options.cloudId); results.reinitializeCloud(); cloud = results.getCloud(); cloud.waitUntilIssueDataDownloaded(); isConnectedToCloud = !(cloud instanceof BugCollectionStorageCloud); Project project = results.getProject(); originalMode = cloud.getMode(); scaryBugs = results.createEmptyCollectionWithMetadata(); for (BugInstance warning : results.getCollection()) { if (!project.getSuppressionFilter().match(warning)) { int rank = BugRanker.findRank(warning); tooOld++; } else { scaryBugs.add(warning);
SortedBugCollection bugCollection = new SortedBugCollection(commandLine.getProject()); if (argCount < args.length) { bugCollection.readXML(args[argCount++]); } else { bugCollection.readXML(System.in); for (BugInstance warning : bugCollection.getCollection()) { if (!reporter.isApplySuppressions() || !bugCollection.getProject().getSuppressionFilter().match(warning)) { int rank = warning.getBugRank(); BugPattern pattern = warning.getBugPattern();
assert project != null; try { writePrologue(xmlOutput); if (withMessages) { computeBugHashes(); getProjectStats().computeFileStats(this); String commonBase = null; for (String s : project.getSourceDirList()) { commonBase = s; } else { commonBase = commonBase.substring(0, commonPrefix(commonBase, s)); getProjectStats().writeXML(xmlOutput, withMessages); for (BugInstance bugInstance : getCollection()) { if (!applySuppressions || !project.getSuppressionFilter().match(bugInstance)) { bugInstance.writeXML(xmlOutput, this, withMessages); writeEpilogue(xmlOutput);
@Test public void testReadAndThenStoreXmlProps() throws Exception { SortedBugCollection origBC = new SortedBugCollection(); origBC.readXML(new StringReader( "<BugCollection version='1.3.10-dev-20100728' sequence='0' timestamp='1280333223462' analysisTimestamp='1280333224881' release=''>" + " <BugInstance type='MS_MUTABLE_ARRAY' priority='1' abbrev='MS' category='MALICIOUS_CODE' instanceHash='1acc5c5b9b7ab9efacede805afe1e53a' instanceOccurrenceNum='0' instanceOccurrenceMax='0' rank='16' ageInDays='108' firstSeen='4/11/10 11:24 AM' reviews='4' consensus='SHOULD_FIX' shouldFix='true'>" origBC.writeXML(outBytes); SortedBugCollection bc = new SortedBugCollection(); bc.readXML(new StringReader(new String(outBytes.toByteArray(), "UTF-8"))); assertEquals(1, bc.getCollection().size()); BugInstance bug = bc.getCollection().iterator().next(); assertEquals("MS_MUTABLE_ARRAY", bug.getBugPattern().getType()); assertEquals("1acc5c5b9b7ab9efacede805afe1e53a", bug.getInstanceHash());
public void report(PrintWriter out) { TreeMap<BugRankCategory, Stats> stats = new TreeMap<BugRankCategory, Stats>(); ProjectStats projectStats = bugCollection.getProjectStats(); Collection<BugInstance> bugs = bugCollection.getCollection(); Cloud cloud = bugCollection.getCloud(); cloud.setMode(Cloud.Mode.COMMUNAL); out.printf("Cloud sync and summary report for %s%n", bugCollection.getProject().getProjectName()); out.printf("Code dated %s%n", new Date(bugCollection.getTimestamp())); out.printf("Code analyzed %s%n", new Date(bugCollection.getAnalysisTimestamp()));
public static void main(String[] args) throws Exception { if (args.length != 2) { System.err.println("Usage: " + RegenerateClassFeatures.class.getName() + " <bug collection> <jar file>"); System.exit(1); } SortedBugCollection bugCollection = new SortedBugCollection(); bugCollection.readXML(args[0]); new RegenerateClassFeatures(bugCollection, args[1]).execute(); bugCollection.writeXML(System.out); } }