From 1ce526c352e6a43d2b480efa0e1e08cb34103f24 Mon Sep 17 00:00:00 2001 From: Andrey Pokhilko Date: Tue, 14 Sep 2021 19:08:32 +0300 Subject: [PATCH 1/9] Add demo files --- Dockerfile.demo | 44 ++++ demo/jenkins-data/config.xml | 42 ++++ .../jobs/Traffic-Comparison-Demo/config.xml | 121 ++++++++++ demo/jenkins-data/locale.xml | 5 + demo/jenkins-data/scripts/har_dump.py | 226 ++++++++++++++++++ demo/jenkins.sh | 6 + 6 files changed, 444 insertions(+) create mode 100644 Dockerfile.demo create mode 100644 demo/jenkins-data/config.xml create mode 100644 demo/jenkins-data/jobs/Traffic-Comparison-Demo/config.xml create mode 100644 demo/jenkins-data/locale.xml create mode 100644 demo/jenkins-data/scripts/har_dump.py create mode 100755 demo/jenkins.sh diff --git a/Dockerfile.demo b/Dockerfile.demo new file mode 100644 index 0000000..026b3f8 --- /dev/null +++ b/Dockerfile.demo @@ -0,0 +1,44 @@ +FROM node:14 as frontend + +WORKDIR /app + +COPY harnic-spa harnic-spa +WORKDIR /app/harnic-spa + +RUN npm install +RUN npm run build + + +FROM jenkins/jenkins + +USER root + +RUN apt update && apt install -y build-essential python3 sudo python3-pip mc psmisc procps +RUN usermod -aG sudo jenkins && sed -i s/[!]// /etc/shadow +# RUN echo "#! /usr/bin/sudo /bin/sh\n/usr/bin/docker \"\$@\"" > /usr/local/bin/docker && chmod +x /usr/local/bin/docker +# RUN echo "PATH=\$PATH:\$HOME/.local/bin" >> /etc/profile + +# env var to tell the version +ENV IMG_LABEL="-image_label-" + +# set the working directory in the container +WORKDIR /app + +# copy the dependencies file to the working directory +COPY --from=frontend /app/harnic-spa harnic-spa +ENV SPA_LOCATION=/app/harnic-spa + +# install dependencies +COPY requirements.txt . +RUN pip3 install -r requirements.txt +RUN python3 -m spacy download en_core_web_sm + +# install backend +COPY harnic harnic +COPY setup.py . + +RUN pip3 install -e . + +WORKDIR / + +USER jenkins diff --git a/demo/jenkins-data/config.xml b/demo/jenkins-data/config.xml new file mode 100644 index 0000000..f1d0a30 --- /dev/null +++ b/demo/jenkins-data/config.xml @@ -0,0 +1,42 @@ + + + + jenkins.diagnostics.ControllerExecutorsNoAgents + jenkins.diagnostics.SecurityIsOffMonitor + + 2.311 + 1 + NORMAL + true + + + false + + ${JENKINS_HOME}/workspace/${ITEM_FULL_NAME} + ${ITEM_ROOTDIR}/builds + + + + + + 0 + 0 + + + + all + false + false + + + + all + 50000 + + + false + + + + false + \ No newline at end of file diff --git a/demo/jenkins-data/jobs/Traffic-Comparison-Demo/config.xml b/demo/jenkins-data/jobs/Traffic-Comparison-Demo/config.xml new file mode 100644 index 0000000..36beb06 --- /dev/null +++ b/demo/jenkins-data/jobs/Traffic-Comparison-Demo/config.xml @@ -0,0 +1,121 @@ + + + + + false + + + + -1 + 10 + -1 + -1 + + + + false + false + + + + 2 + + + https://github.com/up9inc/mockintosh.git + + + + + ** + + + false + + + + true + false + false + false + + + * * * * * + false + + + false + + + # PREPARE +killall python3 || echo Not running +pip3 install -r requirements.txt +pip3 install mitmproxy +(PYTHONPATH=.:./tests_integrated python3 -m mockintosh tests_integrated/integration_config.yaml --interceptor=custom_interceptors.intercept_for_logging --interceptor=custom_interceptors.intercept_for_modifying > ./tests_integrated/server.log 2>&1) & +sleep 5 +curl -vf http://localhost:8001 +curl -vkf https://localhost:8000 +mkdir traffic +(~/.local/bin/mitmdump -vvv --mode regular --ssl-insecure --set block-global=false --listen-port 8888 --set hardump=./traffic/captured.har -s $HOME/scripts/har_dump.py > ./traffic/mitmdump.log 2>&1) & +sleep 5 +HTTP_PROXY=http://localhost:8888 curl -vf http://localhost:8001 +HTTPS_PROXY=http://localhost:8888 curl -vkf https://localhost:8000 +sed -i s/test_conn_status/_test_conn_status/ tests_integrated/tests_integration.py + + + + # RUN +export HTTP_PROXY=http://localhost:8888 +export HTTPS_PROXY=http://localhost:8888 +export NO_PROXY=raw.githubusercontent.com +python3 -m unittest -v tests_integrated.tests_integration.RESTTests + + 1 + + + # POST-PROCESS +killall -SIGUSR1 mitmdump # supposed to trigger HAR write +sleep 5 +ls `pwd`/traffic/captured.har # make sure it was written +killall python3 || echo Not running # shut down mockintosh server + + +BASELINE=$HOME/hars/origin/main + +if ls $BASELINE/latest.har; then + ls -la $BASELINE + python3 -m harnic $BASELINE/latest.har traffic/captured.har +fi + +mkdir -p $HOME/hars/$GIT_BRANCH/ + +cp ./traffic/captured.har $HOME/hars/$GIT_BRANCH/latest.har + + + + + + + + + Traffic Comparison Report + diff_latest.har_captured.har + index.html + true + + true + true + **/* + true + + + + + + + false + + + false + + + \ No newline at end of file diff --git a/demo/jenkins-data/locale.xml b/demo/jenkins-data/locale.xml new file mode 100644 index 0000000..301df23 --- /dev/null +++ b/demo/jenkins-data/locale.xml @@ -0,0 +1,5 @@ + + + en_US + true + \ No newline at end of file diff --git a/demo/jenkins-data/scripts/har_dump.py b/demo/jenkins-data/scripts/har_dump.py new file mode 100644 index 0000000..fdaf0c2 --- /dev/null +++ b/demo/jenkins-data/scripts/har_dump.py @@ -0,0 +1,226 @@ +""" +This inline script can be used to dump flows as HAR files. + +example cmdline invocation: +mitmdump -s ./har_dump.py --set hardump=./dump.har + +filename endwith '.zhar' will be compressed: +mitmdump -s ./har_dump.py --set hardump=./dump.zhar +""" + +import base64 +import json +import os +import signal +import typing # noqa +import zlib +from datetime import datetime +from datetime import timezone + +import mitmproxy +from mitmproxy import connection +from mitmproxy import ctx +from mitmproxy import version +from mitmproxy.net.http import cookies +from mitmproxy.utils import strutils + +HAR: typing.Dict = {} + +# A list of server seen till now is maintained so we can avoid +# using 'connect' time for entries that use an existing connection. +SERVERS_SEEN: typing.Set[connection.Server] = set() + + +def signal_handler(signum, frame): + print("RECEIVED SIGNAL") + done() + + +signal.signal(signal.SIGUSR1, signal_handler) + + +def load(loader): + loader.add_option( + "hardump", str, "", "HAR dump path.", + ) + + +def configure(updated): + HAR.update({ + "log": { + "version": "1.2", + "creator": { + "name": "mitmproxy har_dump", + "version": "0.1", + "comment": "mitmproxy version %s" % version.MITMPROXY + }, + "entries": [] + } + }) + + +def response(flow: mitmproxy.http.HTTPFlow): + """ + Called when a server response has been received. + """ + + # -1 indicates that these values do not apply to current request + ssl_time = -1 + connect_time = -1 + + if flow.server_conn and flow.server_conn not in SERVERS_SEEN: + connect_time = (flow.server_conn.timestamp_tcp_setup - flow.server_conn.timestamp_start) + + if flow.server_conn.timestamp_tls_setup is not None: + ssl_time = (flow.server_conn.timestamp_tls_setup - flow.server_conn.timestamp_tcp_setup) + + SERVERS_SEEN.add(flow.server_conn) + + # Calculate raw timings from timestamps. DNS timings can not be calculated + # for lack of a way to measure it. The same goes for HAR blocked. + # mitmproxy will open a server connection as soon as it receives the host + # and port from the client connection. So, the time spent waiting is actually + # spent waiting between request.timestamp_end and response.timestamp_start + # thus it correlates to HAR wait instead. + timings_raw = { + 'send': flow.request.timestamp_end - flow.request.timestamp_start, + 'receive': flow.response.timestamp_end - flow.response.timestamp_start, + 'wait': flow.response.timestamp_start - flow.request.timestamp_end, + 'connect': connect_time, + 'ssl': ssl_time, + } + + # HAR timings are integers in ms, so we re-encode the raw timings to that format. + timings = { + k: int(1000 * v) if v != -1 else -1 + for k, v in timings_raw.items() + } + + # full_time is the sum of all timings. + # Timings set to -1 will be ignored as per spec. + full_time = sum(v for v in timings.values() if v > -1) + + started_date_time = datetime.fromtimestamp(flow.request.timestamp_start, timezone.utc).isoformat() + + # Response body size and encoding + response_body_size = len(flow.response.raw_content) if flow.response.raw_content else 0 + response_body_decoded_size = len(flow.response.content) if flow.response.content else 0 + response_body_compression = response_body_decoded_size - response_body_size + + entry = { + "startedDateTime": started_date_time, + "time": full_time, + "request": { + "method": flow.request.method, + "url": flow.request.url, + "httpVersion": flow.request.http_version, + "cookies": format_request_cookies(flow.request.cookies.fields), + "headers": name_value(flow.request.headers), + "queryString": name_value(flow.request.query or {}), + "headersSize": len(str(flow.request.headers)), + "bodySize": len(flow.request.content), + }, + "response": { + "status": flow.response.status_code, + "statusText": flow.response.reason, + "httpVersion": flow.response.http_version, + "cookies": format_response_cookies(flow.response.cookies.fields), + "headers": name_value(flow.response.headers), + "content": { + "size": response_body_size, + "compression": response_body_compression, + "mimeType": flow.response.headers.get('Content-Type', '') + }, + "redirectURL": flow.response.headers.get('Location', ''), + "headersSize": len(str(flow.response.headers)), + "bodySize": response_body_size, + }, + "cache": {}, + "timings": timings, + } + + # Store binary data as base64 + if strutils.is_mostly_bin(flow.response.content): + entry["response"]["content"]["text"] = base64.b64encode(flow.response.content).decode() + entry["response"]["content"]["encoding"] = "base64" + else: + entry["response"]["content"]["text"] = flow.response.get_text(strict=False) + + if flow.request.method in ["POST", "PUT", "PATCH"]: + params = [ + {"name": a, "value": b} + for a, b in flow.request.urlencoded_form.items(multi=True) + ] + entry["request"]["postData"] = { + "mimeType": flow.request.headers.get("Content-Type", ""), + "text": flow.request.get_text(strict=False), + "params": params + } + + if flow.server_conn.connected: + entry["serverIPAddress"] = str(flow.server_conn.ip_address[0]) + + HAR["log"]["entries"].append(entry) + + +def done(): + """ + Called once on script shutdown, after any other events. + """ + if ctx.options.hardump: + json_dump: str = json.dumps(HAR, indent=2) + + if ctx.options.hardump == '-': + mitmproxy.ctx.log(json_dump) + else: + raw: bytes = json_dump.encode() + if ctx.options.hardump.endswith('.zhar'): + raw = zlib.compress(raw, 9) + + with open(os.path.expanduser(ctx.options.hardump), "wb") as f: + f.write(raw) + + mitmproxy.ctx.log("HAR dump finished (wrote %s bytes to file)" % len(json_dump)) + + +def format_cookies(cookie_list): + rv = [] + + for name, value, attrs in cookie_list: + cookie_har = { + "name": name, + "value": value, + } + + # HAR only needs some attributes + for key in ["path", "domain", "comment"]: + if key in attrs: + cookie_har[key] = attrs[key] + + # These keys need to be boolean! + for key in ["httpOnly", "secure"]: + cookie_har[key] = bool(key in attrs) + + # Expiration time needs to be formatted + expire_ts = cookies.get_expiration_ts(attrs) + if expire_ts is not None: + cookie_har["expires"] = datetime.fromtimestamp(expire_ts, timezone.utc).isoformat() + + rv.append(cookie_har) + + return rv + + +def format_request_cookies(fields): + return format_cookies(cookies.group_cookies(fields)) + + +def format_response_cookies(fields): + return format_cookies((c[0], c[1][0], c[1][1]) for c in fields) + + +def name_value(obj): + """ + Convert (key, value) pairs to HAR format. + """ + return [{"name": k, "value": v} for k, v in obj.items() if not v.startswith("UP9")] diff --git a/demo/jenkins.sh b/demo/jenkins.sh new file mode 100755 index 0000000..8ca56ee --- /dev/null +++ b/demo/jenkins.sh @@ -0,0 +1,6 @@ +#!/bin/bash -xe + +docker pull gcr.io/mimetic-card-241611/harnic/develop +docker build .. -f ../Dockerfile.demo -t jenkins +docker run -it -p 8080:8080 -v `pwd`/jenkins-data:/var/jenkins_home jenkins +# -v /var/run/docker.sock:/var/run/docker.sock From ed85edfca633a00868199968b56e1a595f9debb2 Mon Sep 17 00:00:00 2001 From: Andrey Pokhilko Date: Tue, 14 Sep 2021 19:58:46 +0300 Subject: [PATCH 2/9] Flag for UI --- Dockerfile.demo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.demo b/Dockerfile.demo index 026b3f8..f5734c7 100644 --- a/Dockerfile.demo +++ b/Dockerfile.demo @@ -40,5 +40,5 @@ COPY setup.py . RUN pip3 install -e . WORKDIR / - +ENV JAVA_OPTS='-Dhudson.model.DirectoryBrowserSupport.CSP=""' USER jenkins From 9c7f09baf5613769e38afb5b6ca219e1770ca282 Mon Sep 17 00:00:00 2001 From: Andrey Pokhilko Date: Tue, 14 Sep 2021 20:17:12 +0300 Subject: [PATCH 3/9] Update props --- Dockerfile.demo | 2 +- demo/jenkins-data/config.xml | 1 + .../jobs/Traffic-Comparison-Demo/config.xml | 28 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Dockerfile.demo b/Dockerfile.demo index f5734c7..8babfbd 100644 --- a/Dockerfile.demo +++ b/Dockerfile.demo @@ -13,7 +13,7 @@ FROM jenkins/jenkins USER root -RUN apt update && apt install -y build-essential python3 sudo python3-pip mc psmisc procps +RUN apt update && apt install -y build-essential python3 sudo python3-pip mc psmisc procps jq RUN usermod -aG sudo jenkins && sed -i s/[!]// /etc/shadow # RUN echo "#! /usr/bin/sudo /bin/sh\n/usr/bin/docker \"\$@\"" > /usr/local/bin/docker && chmod +x /usr/local/bin/docker # RUN echo "PATH=\$PATH:\$HOME/.local/bin" >> /etc/profile diff --git a/demo/jenkins-data/config.xml b/demo/jenkins-data/config.xml index f1d0a30..24c481d 100644 --- a/demo/jenkins-data/config.xml +++ b/demo/jenkins-data/config.xml @@ -3,6 +3,7 @@ jenkins.diagnostics.ControllerExecutorsNoAgents jenkins.diagnostics.SecurityIsOffMonitor + jenkins.security.ResourceDomainRecommendation 2.311 1 diff --git a/demo/jenkins-data/jobs/Traffic-Comparison-Demo/config.xml b/demo/jenkins-data/jobs/Traffic-Comparison-Demo/config.xml index 36beb06..66ba09d 100644 --- a/demo/jenkins-data/jobs/Traffic-Comparison-Demo/config.xml +++ b/demo/jenkins-data/jobs/Traffic-Comparison-Demo/config.xml @@ -84,6 +84,7 @@ BASELINE=$HOME/hars/origin/main if ls $BASELINE/latest.har; then ls -la $BASELINE python3 -m harnic $BASELINE/latest.har traffic/captured.har + echo YVALUE=`cat diff_latest.har_captured.har/kpis.json | jq .stats.with_reorders.ratio` > kpis.properties fi mkdir -p $HOME/hars/$GIT_BRANCH/ @@ -94,6 +95,33 @@ cp ./traffic/captured.har $HOME/hars/$GIT_BRANCH/latest.har + + + + Match Score + + % + + + kpis.properties + + properties + + + Traffic Diff Stats + + + 0 + + false + false + false + false + + + + + From 5fd834337059d01e3c50488e82660ef24fcf9130 Mon Sep 17 00:00:00 2001 From: Andrey Pokhilko Date: Tue, 14 Sep 2021 20:18:04 +0300 Subject: [PATCH 4/9] ignores --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 41742c8..7df06a7 100644 --- a/.gitignore +++ b/.gitignore @@ -168,4 +168,5 @@ harnic-spa/build npm-debug.log* yarn-debug.log* -yarn-error.log* \ No newline at end of file +yarn-error.log* +/demo/jenkins-data/ From 232f6a734b58560c1156a03408e7ded659768d55 Mon Sep 17 00:00:00 2001 From: Andrey Pokhilko Date: Tue, 14 Sep 2021 22:05:17 +0300 Subject: [PATCH 5/9] SAve job settings --- .../jobs/Traffic-Comparison-Demo/config.xml | 119 ++++++++++++++++-- 1 file changed, 109 insertions(+), 10 deletions(-) diff --git a/demo/jenkins-data/jobs/Traffic-Comparison-Demo/config.xml b/demo/jenkins-data/jobs/Traffic-Comparison-Demo/config.xml index 66ba09d..2761f31 100644 --- a/demo/jenkins-data/jobs/Traffic-Comparison-Demo/config.xml +++ b/demo/jenkins-data/jobs/Traffic-Comparison-Demo/config.xml @@ -7,7 +7,7 @@ -1 - 10 + 25 -1 -1 @@ -16,6 +16,23 @@ false false + + + + BRANCH + c7a81730-de40-4eef-907c-b271fcf7a5c5 + PT_BRANCH + + * + .* + NONE + origin/main + NONE + false + 5 + + + 2 @@ -26,7 +43,7 @@ - ** + ${BRANCH} false @@ -78,16 +95,25 @@ sleep 5 ls `pwd`/traffic/captured.har # make sure it was written killall python3 || echo Not running # shut down mockintosh server +mkdir -p $HOME/hars/$GIT_BRANCH/ BASELINE=$HOME/hars/origin/main if ls $BASELINE/latest.har; then - ls -la $BASELINE python3 -m harnic $BASELINE/latest.har traffic/captured.har - echo YVALUE=`cat diff_latest.har_captured.har/kpis.json | jq .stats.with_reorders.ratio` > kpis.properties + cp diff_latest.har_captured.har/kpis.json $HOME/hars/$GIT_BRANCH/ + w_reorders=`cat diff_latest.har_captured.har/kpis.json | jq .stats.with_reorders.ratio` + woreorders=`cat diff_latest.har_captured.har/kpis.json | jq .stats.strict_order.ratio` + echo with_reorders,strict_order > kpis.csv + echo `python3 -c "print($w_reorders*100)"`,`python3 -c "print($woreorders*100)"` >> kpis.csv + + echo matched,modified,added,removed > entries-r.csv + echo `cat diff_latest.har_captured.har/kpis.json | jq .stats.with_reorders.matched`,`cat diff_latest.har_captured.har/kpis.json | jq .stats.with_reorders.modified`,`cat diff_latest.har_captured.har/kpis.json | jq .stats.with_reorders.added`,`cat diff_latest.har_captured.har/kpis.json | jq .stats.with_reorders.removed` >> entries-r.csv + + echo matched,modified,added,removed > entries-n.csv + echo `cat diff_latest.har_captured.har/kpis.json | jq .stats.strict_order.matched`,`cat diff_latest.har_captured.har/kpis.json | jq .stats.strict_order.modified`,`cat diff_latest.har_captured.har/kpis.json | jq .stats.strict_order.added`,`cat diff_latest.har_captured.har/kpis.json | jq .stats.strict_order.removed` >> entries-n.csv fi -mkdir -p $HOME/hars/$GIT_BRANCH/ cp ./traffic/captured.har $HOME/hars/$GIT_BRANCH/latest.har @@ -102,15 +128,88 @@ cp ./traffic/captured.har $HOME/hars/$GIT_BRANCH/latest.har % - - kpis.properties + + kpis.csv + + csv + OFF + + + + + + + + false + + + Traffic Diff Stats + + plot-3205114369520422087.csv + 0 + + false + false + false + false + 50.0 + + + + Items: With Reorders + + number of traffic entries + + + entries-r.csv + + csv + OFF + + + + + + + + false + + + Traffic Diff Stats + + plot-7979134032686517538.csv + 0 + + false + false + false + false + + + + + Items: Strict Order + + number of traffic entries + + + entries-n.csv - properties - + csv + OFF + + + + + + + + false + Traffic Diff Stats - + plot-2287905576478828014.csv 0 false From 5a68a9acb95daaebffc7d33a41a71271e1af79a3 Mon Sep 17 00:00:00 2001 From: Andrey Pokhilko Date: Tue, 14 Sep 2021 22:49:43 +0300 Subject: [PATCH 6/9] Make it reproducible --- Dockerfile.demo | 1 + demo/jenkins.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile.demo b/Dockerfile.demo index 8babfbd..e4c2b69 100644 --- a/Dockerfile.demo +++ b/Dockerfile.demo @@ -17,6 +17,7 @@ RUN apt update && apt install -y build-essential python3 sudo python3-pip mc psm RUN usermod -aG sudo jenkins && sed -i s/[!]// /etc/shadow # RUN echo "#! /usr/bin/sudo /bin/sh\n/usr/bin/docker \"\$@\"" > /usr/local/bin/docker && chmod +x /usr/local/bin/docker # RUN echo "PATH=\$PATH:\$HOME/.local/bin" >> /etc/profile +RUN jenkins-plugin-cli --verbose --plugins ws-clean git dashboard-view htmlpublisher locale plot # env var to tell the version ENV IMG_LABEL="-image_label-" diff --git a/demo/jenkins.sh b/demo/jenkins.sh index 8ca56ee..4e597aa 100755 --- a/demo/jenkins.sh +++ b/demo/jenkins.sh @@ -1,6 +1,6 @@ #!/bin/bash -xe -docker pull gcr.io/mimetic-card-241611/harnic/develop +# docker pull gcr.io/mimetic-card-241611/harnic/develop docker build .. -f ../Dockerfile.demo -t jenkins docker run -it -p 8080:8080 -v `pwd`/jenkins-data:/var/jenkins_home jenkins # -v /var/run/docker.sock:/var/run/docker.sock From fd6a30b6bfb1348375668bf89b3e631fd9c312d9 Mon Sep 17 00:00:00 2001 From: Andrey Pokhilko Date: Wed, 15 Sep 2021 00:06:20 +0300 Subject: [PATCH 7/9] fix plugin name --- Dockerfile.demo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.demo b/Dockerfile.demo index e4c2b69..8bd9f1d 100644 --- a/Dockerfile.demo +++ b/Dockerfile.demo @@ -17,7 +17,7 @@ RUN apt update && apt install -y build-essential python3 sudo python3-pip mc psm RUN usermod -aG sudo jenkins && sed -i s/[!]// /etc/shadow # RUN echo "#! /usr/bin/sudo /bin/sh\n/usr/bin/docker \"\$@\"" > /usr/local/bin/docker && chmod +x /usr/local/bin/docker # RUN echo "PATH=\$PATH:\$HOME/.local/bin" >> /etc/profile -RUN jenkins-plugin-cli --verbose --plugins ws-clean git dashboard-view htmlpublisher locale plot +RUN jenkins-plugin-cli --verbose --plugins ws-cleanup git dashboard-view htmlpublisher locale plot # env var to tell the version ENV IMG_LABEL="-image_label-" From 1774adfa2eb8367015c79823daebc7a25459f771 Mon Sep 17 00:00:00 2001 From: Andrey Pokhilko Date: Wed, 15 Sep 2021 20:14:44 +0300 Subject: [PATCH 8/9] Fixes --- Dockerfile.demo | 3 +-- demo/jenkins-data/config.xml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile.demo b/Dockerfile.demo index 8bd9f1d..97adcc9 100644 --- a/Dockerfile.demo +++ b/Dockerfile.demo @@ -17,7 +17,7 @@ RUN apt update && apt install -y build-essential python3 sudo python3-pip mc psm RUN usermod -aG sudo jenkins && sed -i s/[!]// /etc/shadow # RUN echo "#! /usr/bin/sudo /bin/sh\n/usr/bin/docker \"\$@\"" > /usr/local/bin/docker && chmod +x /usr/local/bin/docker # RUN echo "PATH=\$PATH:\$HOME/.local/bin" >> /etc/profile -RUN jenkins-plugin-cli --verbose --plugins ws-cleanup git dashboard-view htmlpublisher locale plot +# RUN jenkins-plugin-cli --verbose --plugins ws-cleanup git dashboard-view htmlpublisher locale plot # env var to tell the version ENV IMG_LABEL="-image_label-" @@ -32,7 +32,6 @@ ENV SPA_LOCATION=/app/harnic-spa # install dependencies COPY requirements.txt . RUN pip3 install -r requirements.txt -RUN python3 -m spacy download en_core_web_sm # install backend COPY harnic harnic diff --git a/demo/jenkins-data/config.xml b/demo/jenkins-data/config.xml index 24c481d..4e5484c 100644 --- a/demo/jenkins-data/config.xml +++ b/demo/jenkins-data/config.xml @@ -5,7 +5,7 @@ jenkins.diagnostics.SecurityIsOffMonitor jenkins.security.ResourceDomainRecommendation - 2.311 + 2.312 1 NORMAL true From 791c10a96241284c84327e8f3c5f9b452ac66edf Mon Sep 17 00:00:00 2001 From: Andrey Pokhilko Date: Fri, 17 Sep 2021 14:16:47 +0300 Subject: [PATCH 9/9] Flag for status code --- harnic/objects.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/harnic/objects.py b/harnic/objects.py index 8596b8f..b14f5e9 100644 --- a/harnic/objects.py +++ b/harnic/objects.py @@ -2,6 +2,7 @@ import codecs import copy import json +import os import re from json import JSONDecodeError from urllib.parse import urlparse, parse_qs, urlencode @@ -46,7 +47,8 @@ def __repr__(self): return f"{self.request['method']} {self.request['url'].clean_url}" def _key(self): - return self.request['method'], self.request['url'].clean_url, self.response['status'] + status = self.response['status'] if os.getenv("HARNIC_STATUS_DIFFERENTIATES") else None + return self.request['method'], self.request['url'].clean_url, status def __hash__(self): return hash(self._key())