FortifyRulesDefinition implements RulesDefinition { @Override public void define(Context context) { List<RulePack> rulePacks = this.rulePackParser.parse(); parseXml(context); parseRulePacks(context, rulePacks); for (NewRepository newRepository : newRepositories.values()) { newRepository.done(); } } FortifyRulesDefinition(Settings settings, Languages languages, RulesDefinitionXmlLoader xmlLoader); @VisibleForTesting  FortifyRulesDefinition(RulePackParser rulePackParser, Languages languages, RulesDefinitionXmlLoader xmlLoader); @Override void define(Context context);  }
@Test public void create_rules_from_xml_definition_and_rulepack() { Settings settings = new Settings(); settings.setProperty(FortifyConstants.RULEPACK_PATHS_PROPERTY, "src/test/resources/rulepack,src/test/resources/rulepack/other-rulepack.xml"); RulePackParser parser = new RulePackParser(settings); Languages languages = new Languages(language("java"), language("plsql")); RulesDefinition.Context context = new RulesDefinition.Context(); new FortifyRulesDefinition(parser, languages, new RulesDefinitionXmlLoader()).define(context); assertThat(context.repository("fortify-java")).isNotNull(); assertThat(context.repository("fortify-java").rules()).isNotEmpty(); assertThat(context.repository("fortify-plsql")).isNotNull(); assertThat(context.repository("fortify-plsql").rules()).isNotEmpty(); }
@Test public void create_flex_rules() { Settings settings = new Settings(); settings.setProperty(FortifyConstants.RULEPACK_PATHS_PROPERTY, "src/test/resources/rulepack/actionscript-rulepack.xml"); RulePackParser parser = new RulePackParser(settings); Languages languages = new Languages(language("flex")); RulesDefinition.Context context = new RulesDefinition.Context(); new FortifyRulesDefinition(parser, languages, new RulesDefinitionXmlLoader()).define(context); assertThat(context.repository("fortify-flex").rules()).isNotEmpty(); }
@Test public void create_js_rules() { Settings settings = new Settings(); settings.setProperty(FortifyConstants.RULEPACK_PATHS_PROPERTY, "src/test/resources/rulepack/javascript-rulepack.xml"); RulePackParser parser = new RulePackParser(settings); Languages languages = new Languages(language("js")); RulesDefinition.Context context = new RulesDefinition.Context(); new FortifyRulesDefinition(parser, languages, new RulesDefinitionXmlLoader()).define(context); assertThat(context.repository("fortify-js").rules()).isNotEmpty(); }