Mercurial > stress-tester
changeset 1235:5dc2ff622d6c
flow - folding
author | Devel 1 |
---|---|
date | Mon, 29 Jun 2020 21:45:45 +0200 |
parents | e0985c791eae |
children | d526a06722f7 |
files | stress-tester/src/main/java/com/passus/st/scanner/FlowAnalyzerCommand.java stress-tester/src/main/java/com/passus/st/scanner/HttpUrlSequencePayloadAnalyzer.java stress-tester/src/main/resources/flow_analyzer.py |
diffstat | 3 files changed, 24 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/scanner/FlowAnalyzerCommand.java Mon Jun 29 14:12:03 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/scanner/FlowAnalyzerCommand.java Mon Jun 29 21:45:45 2020 +0200 @@ -20,7 +20,7 @@ public static final String DEFAULT_PYTHON_CMD = IS_WINDOWS ? "python" : "python3"; public static final String DEFAULT_SCRIPT_PATH = "flow_analyzer.py"; public static final String RESOURCE = "/flow_analyzer.py"; - public static final float DEFAULT_PMIN = 0.005f; + public static final float DEFAULT_PMIN = 0.007f; public static final int DEFAULT_LMIN = 3; public static final int DEFAULT_LMAX = 7; public static final int DEFAULT_MAX_SEQ = 10;
--- a/stress-tester/src/main/java/com/passus/st/scanner/HttpUrlSequencePayloadAnalyzer.java Mon Jun 29 14:12:03 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/scanner/HttpUrlSequencePayloadAnalyzer.java Mon Jun 29 21:45:45 2020 +0200 @@ -154,7 +154,8 @@ File dir = new File("."); Gson gson = new Gson(); - Pattern pattern = Pattern.compile("^seq_(L\\d+)[.]json$"); + String patternStr = command.fold ? "^seq_(L\\d+)f[.]json$" : "^seq_(L\\d+)[.]json$"; + Pattern pattern = Pattern.compile(patternStr); for (String fname : dir.list()) { Matcher m = pattern.matcher(fname); if (m.matches()) {
--- a/stress-tester/src/main/resources/flow_analyzer.py Mon Jun 29 14:12:03 2020 +0200 +++ b/stress-tester/src/main/resources/flow_analyzer.py Mon Jun 29 21:45:45 2020 +0200 @@ -666,7 +666,7 @@ parser = argparse.ArgumentParser('Flow Analyzer') parser.add_argument('input') parser.add_argument('-c', nargs='+') - parser.add_argument('-pmin', type=float, default=0.005) + parser.add_argument('-pmin', type=float, default=0.007) parser.add_argument('-lmin', type=int, default=3) parser.add_argument('-lmax', type=int, default=7) parser.add_argument('-maxSeq', type=int, default=100) @@ -692,24 +692,26 @@ for length in range(args.lmin, args.lmax + 1): if args.fold: - suffix = '_fold' + suffix = 'f' res = analyzer.analyze_markov_fold(targetLength=length, foldLoops=True) seqs_prob = [(s, prob) for s, prob in res if prob >= args.pmin] - seqs_only = [s for s, prob in res if prob >= args.pmin] - seqs = expand(seqs_only, analyzer.markovLoopsMapped) + seqs = [s for s, prob in res if prob >= args.pmin] + loops = analyzer.markovLoopsMapped + seqs_exp = expand(seqs, loops) stats = { 'seqCount': len(res), - 'seqCountP': len(seqs_only), - 'loopCount': len(analyzer.markovLoopsMapped), - 'expandedCount': len(seqs) + 'seqCountP': len(seqs), + 'loopCount': len(loops), + 'expandedCount': len(seqs_exp) } + seqs = seqs[:args.maxSeq] seqs_prob = seqs_prob[:args.maxSeq] - seqs_only = seqs_only[:args.maxSeq] else: suffix = '' res = analyzer.analyze_markov(targetLength=length) seqs_prob = [(s, prob) for s, prob in res if prob >= args.pmin] seqs = [s for s, prob in res if prob >= args.pmin] + loops = None stats = { 'seqCount': len(res), 'seqCountP': len(seqs) @@ -717,9 +719,16 @@ seqs = seqs[:args.maxSeq] seqs_prob = seqs_prob[:args.maxSeq] + # for metrics + with open("seq_L{}{}.json".format(length, suffix), "w") as f: + json.dump(seqs, f) + # input to next stage + with open("seq_L{}{}_prob.json".format(length, suffix), "w") as f: + json.dump(seqs_prob, f) + # debug with open("seq_L{}{}_stats.json".format(length, suffix), "w") as f: json.dump(stats, f) - with open("seq_L{}{}_prob.json".format(length, suffix), "w") as f: - json.dump(seqs_prob, f) - with open("seq_L{}{}.json".format(length, suffix), "w") as f: - json.dump(seqs, f) + # input to next stage + if loops: + with open("seq_L{}{}_loops.json".format(length, suffix), "w") as f: + json.dump(loops, f)