diff options
author | Benjamin Jones <bjones@galois.com> | 2013-02-21 15:47:52 -0800 |
---|---|---|
committer | Benjamin Jones <bjones@galois.com> | 2013-02-21 15:47:52 -0800 |
commit | 5ce8b1db05accf8d4a7db4bb478796ca169a86a8 (patch) | |
tree | 0585be616b835b3ae20d636def445c5a1c4d4242 | |
parent | 523904ce844a541ed65b1668ecd9e1aeb16af8cb (diff) |
fixed filename case bug in the HTML reports
-rw-r--r-- | headless/src/main/java/com/galois/fiveui/HeadlessRunner.java | 40 | ||||
-rw-r--r-- | headless/src/main/java/com/galois/fiveui/Reporter.java | 64 |
2 files changed, 52 insertions, 52 deletions
diff --git a/headless/src/main/java/com/galois/fiveui/HeadlessRunner.java b/headless/src/main/java/com/galois/fiveui/HeadlessRunner.java index 302dd6d..aba0ad7 100644 --- a/headless/src/main/java/com/galois/fiveui/HeadlessRunner.java +++ b/headless/src/main/java/com/galois/fiveui/HeadlessRunner.java @@ -1,14 +1,14 @@ /** * Module : HeadlessRunner.java Copyright : (c) 2012, Galois, Inc. - * + * * Maintainer : Stability : Provisional Portability: Portable - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -45,19 +45,19 @@ import org.apache.log4j.BasicConfigurator; * a headless run description from disk, and executes the run which includes * loading seed URL's, performing a webcrawl, and running rule sets on each of * the crawled pages. - * + * * @author bjones - * + * */ public class HeadlessRunner { private static Logger logger = Logger.getLogger("com.galois.fiveui.HeadlessRunner"); - + /** * @param args list of headless run description filenames * @throws IOException * @throws URISyntaxException - * @throws ParseException + * @throws ParseException */ @SuppressWarnings("static-access") public static void main(final String[] args) @@ -79,7 +79,7 @@ public class HeadlessRunner { options.addOption("v", false, "verbose output"); options.addOption("vv", false, "VERY verbose output"); options.addOption(help); - + // Parse command line options CommandLineParser parser = new GnuParser(); CommandLine cmd = null; @@ -89,14 +89,14 @@ public class HeadlessRunner { System.err.println( "Command line option parsing failed. Reason: " + e.getMessage() ); System.exit(1); } - + // Display help if requested if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("headless <input file 1> [<input file 2> ...]", options); System.exit(1); - } - + } + // Set logging levels BasicConfigurator.configure(); Logger fiveuiLogger = Logger.getLogger("com.galois.fiveui"); @@ -111,7 +111,7 @@ public class HeadlessRunner { fiveuiLogger.setLevel(Level.ERROR); rootLogger.setLevel(Level.ERROR); } - + // Setup output file if requested PrintWriter outStream = null; if (cmd.hasOption("o")) { @@ -125,8 +125,8 @@ public class HeadlessRunner { } else { outStream = new PrintWriter(new BufferedWriter(new PrintWriter(System.out))); } - - // Setup HTML reports directory before the major work happens in case we + + // Setup HTML reports directory before the major work happens in case we // have to throw an exception. PrintWriter summaryFile = null; PrintWriter byURLFile = null; @@ -148,8 +148,8 @@ public class HeadlessRunner { System.err.println("could not open report directory / files for writing"); System.exit(1); } - } - + } + // Major work: process input files ImmutableList<Result> results = null; for (String in: cmd.getArgs()) { @@ -165,7 +165,7 @@ public class HeadlessRunner { outStream.flush(); } outStream.close(); - + // Write report files if requested if (cmd.hasOption("r") && results != null) { Reporter kermit = new Reporter(results); @@ -175,7 +175,7 @@ public class HeadlessRunner { byURLFile.close(); byRuleFile.write(kermit.getByRule()); byRuleFile.close(); - } - } + } + } } diff --git a/headless/src/main/java/com/galois/fiveui/Reporter.java b/headless/src/main/java/com/galois/fiveui/Reporter.java index a1d8b9a..5c0b233 100644 --- a/headless/src/main/java/com/galois/fiveui/Reporter.java +++ b/headless/src/main/java/com/galois/fiveui/Reporter.java @@ -14,7 +14,7 @@ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. - * + * * @author Benjamin Jones <bjones@galois.com> */ package com.galois.fiveui; @@ -40,13 +40,13 @@ import com.googlecode.jatl.Html; * generated in HTML and returned as human readable strings by getSummaryPage(), * getURLPage(), and getRulePage(). The client is responsible for writing them * to .html files (or whatever). - * + * * @author bjones * */ public class Reporter { - - /** see sortBy* and computeSummaryStats methods for map semantics */ + + /** see sortBy* and computeSummaryStats methods for map semantics */ private final Map<String, List<Result>> _byURLMap; private final Map<String, List<Result>> _byRuleMap; private final Map<String, int[]> _passFailMap; @@ -63,11 +63,11 @@ public class Reporter { "td, th { border: 1px solid grey; }\n" + ".hlRow { background: #EEEEEE; }\n" + ".regRow { background: #FFFFFF; }\n"; - + /** * Construct a Reporter object. The constructor takes a list of results * and uses them to populate various maps used in reporting. - * + * * @param results a list of Result objects */ public Reporter(List<Result> results) { @@ -76,11 +76,11 @@ public class Reporter { this._passFailMap = computeSummaryStats(results); this._ruleNameToDesc = extractRuleDesc(results); } - + /** * Build the HTML markup for a summary page based on the precomputed map * this._passFailMap. - * + * * @return String containing human-readable HTML representing a summary page */ public String getSummary() { @@ -92,8 +92,8 @@ public class Reporter { h1().text("Headless Run Summary").end(); p(); ul(); - li().a().href("byurl.html").text("Results organized by URL").end().end(); - li().a().href("byrule.html").text("Results organized by Rule").end().end(); + li().a().href("byUrl.html").text("Results organized by URL").end().end(); + li().a().href("byRule.html").text("Results organized by Rule").end().end(); end(); end(); p(); @@ -107,17 +107,17 @@ public class Reporter { /** * Report statistics on the headless run. Note, "pass" * means the URL passed all tests in the ruleset, but "fail" can be - * reported for the same test on multiple offenders in the page. + * reported for the same test on multiple offenders in the page. */ Html makeSummaryStats(Map<String, int[]> passFailMap) { int uniqueURLs = passFailMap.size(); int[] passFailList; - + p(); h3().text("Unique URLs: "); span().classAttr("number").text(String.valueOf(uniqueURLs)).end(); end().end(); - + p(); table().id("stats-table"); tr(); @@ -144,10 +144,10 @@ public class Reporter { }; return summaryPage.getBuffer().toString(); } - + /** * Build the HTML markup for a report page sorted by URL. - * + * * @return String containing human-readable HTML representing a report page */ public String getByURL() { @@ -180,10 +180,10 @@ public class Reporter { }}; return byURLPage.getBuffer().toString(); } - + /** * Build the HTML markup for a report page sorted by rule name. - * + * * @return String containing human-readable HTML representing a report page */ public String getByRule() { @@ -217,11 +217,11 @@ public class Reporter { }}; return byRulePage.getBuffer().toString(); } - + /** * Utility method to take all the reports and write them to standard file * names under a given directory. - * + * * @param dirName name of the directory where the reports should be written * @throws IOException */ @@ -236,9 +236,9 @@ public class Reporter { byRuleFile.write(this.getByRule()); byRuleFile.close(); } - + /** Private fields **/ - + private Html makeHead(Html page, final String title) { return new Html(page) {{ html(); @@ -249,11 +249,11 @@ public class Reporter { body(); }}; } - + /** * Populate a Map<String, List<Result>> representing the results sorted by * URL. - * + * * @param results a list of results * @return a map representing the results sorted by URL. */ @@ -275,11 +275,11 @@ public class Reporter { } return map; } - + /** * Populate a Map<String, List<Result>> representing the results sorted by * rule name. - * + * * @param results a list of results * @return a map representing the results sorted by rule name. */ @@ -301,11 +301,11 @@ public class Reporter { } return map; } - + /** * Build a map of ruleName -> ruleDesc entries occurring in the given list of * results. - * + * * @param results a list of results * @return a map associating rule names to rule descriptions */ @@ -316,15 +316,15 @@ public class Reporter { assoc.put(r.getRuleName(), r.getRuleDesc()); return assoc; } - + /** * Compute summary statistics from the results list. This includes number of * passes and fails for each URL checked. - * + * * @param results a list of results * @return a map representing the results sorted by rule name. */ - private Map<String, int[]> computeSummaryStats(List<Result> results) { + private Map<String, int[]> computeSummaryStats(List<Result> results) { /** passFailMap semantics: Map<url, {#pass, #fail}> */ Map<String, int[]> passFailMap = new HashMap<String, int[]>(); String url; @@ -332,7 +332,7 @@ public class Reporter { int[] passFailList; Pattern numberPassedPattern = Pattern.compile("passed ([0-9]+) tests"); Matcher matcher; - + for (Result result : results) { pass = fail = 0; url = result.getURL(); @@ -345,7 +345,7 @@ public class Reporter { // each error result corresponds to one test fail = 1; } - + if (passFailMap.containsKey(url)) { passFailList = passFailMap.get(url); } else { |