/** * Gets a human readable description of the location in the file */ default String getDescription() { if (null == getSourceSnippit()) return ""; return StringEscapeUtils.escapeHtml4( StringUtils.substringBefore(StringUtils.abbreviate(getSourceSnippit().trim(), MAX_DESC_WIDTH), System.lineSeparator())); }
/** * Gets a human readable description of the location in the file */ default String getDescription() { if (null == getSourceSnippit()) return ""; return StringEscapeUtils.escapeHtml4( StringUtils.substringBefore(StringUtils.abbreviate(getSourceSnippit().trim(), MAX_DESC_WIDTH), System.lineSeparator())); }
/** * if this is a maven file, checks to see if "version" tags match the discovered text; if the discovered text does match something in a version * tag, it is likely a version, not an IP address * * @param context * @param model * @return */ private boolean isMavenVersionTag(GraphContext context, FileLocationModel model) { if (isMavenFile(context, model)) { Document doc = ((XmlFileModel) model.getFile()).asDocument(); for (Element elm : $(doc).find("version")) { String text = StringUtils.trim($(elm).text()); if (StringUtils.equals(text, model.getSourceSnippit())) { return true; } } } return false; }
public void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { // for all file location models that match the regular expression in the where clause, add // the IP Location Model to the graph if (InetAddressValidator.getInstance().isValid(payload.getSourceSnippit())) { // if the file is a property file, make sure the line isn't commented out. if (ignoreLine(event.getGraphContext(), payload)) { return; } if (payload.getFile() instanceof SourceFileModel) ((SourceFileModel) payload.getFile()).setGenerateSourceReport(true); HardcodedIPLocationModel location = GraphService.addTypeToModel(event.getGraphContext(), payload, HardcodedIPLocationModel.class); location.setRuleID(((Rule) context.get(Rule.class)).getId()); location.setTitle("Hard-coded IP address"); StringBuilder hintBody = new StringBuilder("**Hard-coded IP: "); hintBody.append(payload.getSourceSnippit()); hintBody.append("**"); hintBody.append(System.lineSeparator()+System.lineSeparator()); hintBody.append("When migrating environments, hard-coded IP addresses may need to be modified or eliminated."); location.setHint(hintBody.toString()); //location.setIssueCategory(IssueCategoryRegistry.loadFromGraph(event.getGraphContext(), IssueCategoryRegistry.MANDATORY)); location.setIssueCategory(IssueCategoryRegistry.loadFromGraph(event.getGraphContext(), IssueCategoryRegistry.CLOUD_MANDATORY)); location.setEffort(1); } } })
public void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { // for all file location models that match the regular expression in the where clause, add // the IP Location Model to the graph if (InetAddressValidator.getInstance().isValid(payload.getSourceSnippit())) { // if the file is a property file, make sure the line isn't commented out. if (ignoreLine(event.getGraphContext(), payload)) { return; } if (payload.getFile() instanceof SourceFileModel) ((SourceFileModel) payload.getFile()).setGenerateSourceReport(true); HardcodedIPLocationModel location = GraphService.addTypeToModel(event.getGraphContext(), payload, HardcodedIPLocationModel.class); location.setRuleID(((Rule) context.get(Rule.class)).getId()); location.setTitle("Hard-coded IP address"); StringBuilder hintBody = new StringBuilder("**Hard-coded IP: "); hintBody.append(payload.getSourceSnippit()); hintBody.append("**"); hintBody.append(System.lineSeparator()+System.lineSeparator()); hintBody.append("When migrating environments, hard-coded IP addresses may need to be modified or eliminated."); location.setHint(hintBody.toString()); //location.setIssueCategory(IssueCategoryRegistry.loadFromGraph(event.getGraphContext(), IssueCategoryRegistry.MANDATORY)); location.setIssueCategory(IssueCategoryRegistry.loadFromGraph(event.getGraphContext(), IssueCategoryRegistry.CLOUD_MANDATORY)); location.setEffort(1); } } })
/** * if this is a maven file, checks to see if "version" tags match the discovered text; if the discovered text does match something in a version * tag, it is likely a version, not an IP address * * @param context * @param model * @return */ private boolean isMavenVersionTag(GraphContext context, FileLocationModel model) { if (isMavenFile(context, model)) { Document doc = ((XmlFileModel) model.getFile()).asDocument(); for (Element elm : $(doc).find("version")) { String text = StringUtils.trim($(elm).text()); if (StringUtils.equals(text, model.getSourceSnippit())) { return true; } } } return false; }