public boolean isOfInterest(T fileMeta) { // if we found a blacklist, it is of interest. return fileMeta.getDecorations().size() > 0; }
@Override public void processMeta(FileMetadata file) { for (AbstractDecoration dr : file.getDecorations()) { for (ResultProcessor hp : hintProcessors) { hp.process(dr); } } } }
protected List<AbstractDecoration> matchResults(FileMetadata meta) { List<AbstractDecoration> results = new LinkedList<AbstractDecoration>(); for (AbstractDecoration rst : meta.getDecorations()) { if (regexPattern.matcher(rst.getPattern()).find()) { results.add(rst); } } return results; }
@Override public void processMeta(FileMetadata file) { List<AbstractDecoration> retractList = new LinkedList<AbstractDecoration>(); for (AbstractDecoration dr : file.getDecorations()) { for (MatchingProcessor hp : whitelistProcessors) { if (hp.process(dr)) { // retract from the decorations. retractList.add(dr); } } } if (LOG.isDebugEnabled()) { LOG.debug("Retracting: " + retractList.size() + " decorations."); } // method used to avoid concurrent modification exception. for (AbstractDecoration dr : retractList) { boolean retracted = file.getDecorations().remove(dr); if (LOG.isDebugEnabled()) { LOG.debug("Retracting: " + dr.toString() + " :: " + retracted); } } } }
@Override protected List<AbstractDecoration> matchResults(FileMetadata meta) { List<AbstractDecoration> results = new LinkedList<AbstractDecoration>(); for (AbstractDecoration dr : meta.getDecorations()) { if (dr instanceof JavaLine) { JavaLine result = (JavaLine) dr; if (sourceType != null) { if (result.getSourceType() != sourceType) { // not of interest. continue; } } if (regexPattern.matcher(dr.getPattern()).find()) { results.add(dr); } } } return results; } }
@Override public void processMeta(FileMetadata file) { for (AbstractDecoration dr : file.getDecorations()) { if (LOG.isDebugEnabled()) { LOG.debug("Applying notification to: " + matchingProcessors.size() + " for decoration: " + dr.getPattern()); } for (MatchingProcessor hp : matchingProcessors) { // if it matches, set it. if (hp.process(dr)) { if (LOG.isDebugEnabled()) { LOG.debug("Matched. Setting Notification: " + notificationLevel); } dr.setLevel(notificationLevel); } } } } }
@Override public void processMeta(FileMetadata file) { for (AbstractDecoration dr : file.getDecorations()) { if (LOG.isDebugEnabled()) { LOG.debug("Applying notification to: " + matchingProcessors.size() + " for decoration: " + dr.getPattern()); } for (MatchingProcessor hp : matchingProcessors) { // if it matches, set it. if (hp.process(dr)) { if (LOG.isDebugEnabled()) { LOG.debug("Matched. Setting Notification: " + notificationLevel); } dr.setLevel(notificationLevel); } } } } }
public void processMeta(FileMetadata file) { Global gr = new Global(); gr.setDescription(description); gr.setEffort(effort); file.getDecorations().add(gr); } }
public void processMeta(FileMetadata file) { Summary gr = new Summary(); gr.setDescription(description); gr.setEffort(effort); file.getDecorations().add(gr); } }
public void processMeta(FileMetadata file) { Link lr = new Link(); lr.setDescription(description); lr.setLink(link); file.getDecorations().add(lr); } }
@Override public void processMeta(FileMetadata meta) { try { FileInputStream fis = new FileInputStream(meta.getFilePointer()); String md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis); Hash result = new Hash(); result.setHashType(HashType.MD5); result.setHash(md5); meta.getDecorations().add(result); if (LOG.isDebugEnabled()) { LOG.debug("File: " + meta.getFilePointer().getAbsolutePath() + " : MD5: " + md5); } chainDecorators(meta); } catch (Exception e) { LOG.error("Exception generating MD5.", e); } } }
@Override protected List<AbstractDecoration> matchResults(FileMetadata meta) { // only process classification. List<AbstractDecoration> matched = super.matchResults(meta); List<AbstractDecoration> results = new ArrayList<AbstractDecoration>(1); if (matched != null && matched.size() > 0) { // create classification, with the same pattern. Classification cr = new Classification(); cr.setDescription(matchDescription); cr.setEffort(effort); cr.setPattern(matched.get(0).getPattern()); meta.getDecorations().add(cr); results.add(cr); } return results; } }
@Override public void processMeta(FileMetadata meta) { try { String contents = FileUtils.readFileToString(meta.getFilePointer()); Matcher matcher = regexPattern.matcher(contents); while (matcher.find()) { String matched = matcher.group(1); Line lr = new Line(); lr.setDescription("Blacklist Namespace: " + matched); lr.setLineNumber(NewLineUtil.countNewLine(contents, matcher.start())); lr.setPattern(matched); meta.getDecorations().add(lr); } } catch (IOException e) { LOG.error("Exception reading content for: " + meta.getFilePointer().getAbsolutePath(), e); } } }
@Override public void processMeta(FileMetadata meta) { try { FileInputStream fis = new FileInputStream(meta.getFilePointer()); String sha1 = org.apache.commons.codec.digest.DigestUtils.sha1Hex(fis); Hash result = new Hash(); result.setHashType(HashType.SHA1); result.setHash(sha1); meta.getDecorations().add(result); if (LOG.isDebugEnabled()) { LOG.debug("File: " + meta.getFilePointer().getAbsolutePath() + " : SHA1: " + sha1); } chainDecorators(meta); } catch (Exception e) { LOG.error("Exception generating MD5.", e); } }
public void processMeta(FileMetadata file) { Classification gr = new Classification(); gr.setDescription(description); if (effort != null) { StoryPointEffort hours = new StoryPointEffort(); hours.setHours(effort); gr.setEffort(hours); } file.getDecorations().add(gr); } }
@Override public XmlMetadata archiveEntryToMeta(ZipEntryMetadata archiveEntry) { File file = archiveEntry.getFilePointer(); LOG.debug("Processing XML: " + file.getAbsolutePath()); FileMetadata meta = null; if (file.length() > 1048576L * 1) { LOG.warn("XML larger than 1 MB: " + file.getAbsolutePath() + "; Skipping processing."); meta = new FileMetadata(); meta.setArchiveMeta(archiveEntry.getArchiveMeta()); meta.setFilePointer(file); Summary sr = new Summary(); sr.setDescription("File is too large; skipped."); sr.setLevel(NotificationLevel.WARNING); meta.getDecorations().add(sr); } else { XmlMetadata xmlMeta = new XmlMetadata(); xmlMeta.setArchiveMeta(archiveEntry.getArchiveMeta()); xmlMeta.setFilePointer(file); meta = xmlMeta; return xmlMeta; } return null; }
sr.setDescription("File is too large; skipped."); sr.setLevel(NotificationLevel.WARNING); meta.getDecorations().add(sr);
for (AbstractDecoration dr : ir.getDecorations()) { if (dr instanceof Classification) { String tempDesc = dr.getDescription();