enowars5-service-stldoctor

STL-Analyzing A/D Service for ENOWARS5 in 2021
git clone https://git.sinitax.com/sinitax/enowars5-service-stldoctor
Log | Files | Refs | README | LICENSE | sfeed.txt

commit bc05a77222267eeb4fdc6229d2f34c883ba7c056
parent 3d0e670b1c6d24036007c6e4d3419468170eb6c3
Author: Louis Burda <quent.burda@gmail.com>
Date:   Fri,  9 Jul 2021 02:21:28 +0200

moved local check start out of checker folder, merged havocids into fakeid and created extra type of id which is only lower alphanumeric

Diffstat:
Dchecker/local.sh | 14--------------
Mchecker/src/checker.py | 25+++++++++++++++----------
Mdo.sh | 14++++++++++++++
3 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/checker/local.sh b/checker/local.sh @@ -1,14 +0,0 @@ -#!/bin/sh - -if [ -z "$(docker ps | grep stldoctor-mongo)" ]; then - docker-compose down -v - docker-compose up -d stldoctor-mongo -fi - -export MONGO_ENABLED=1 -export MONGO_HOST=localhost -export MONGO_PORT=27017 -export MONGO_USER=stldoctor_checker -export MONGO_PASSWORD=stldoctor_checker - -python3 -u src/checker.py $@ diff --git a/checker/src/checker.py b/checker/src/checker.py @@ -173,22 +173,28 @@ def leetify(clean: str) -> str: return "".join([conv[c] if c in conv else c for c in out]) -def fakeid(havoc: bool = False, minlen: int = 20, maxlen: int = 60) -> bytes: - if havoc: +def fakeid(minlen: int = 25, maxlen: int = 50) -> bytes: + choice = rand.randint(0, 2) + if choice == 0: # most random without hurting parsing idlen = rand.randint(minlen, maxlen) - return bytes([rand.randint(32, 127) for i in range(idlen)]) - else: + return bytes([rand.randint(33, 127) for i in range(idlen)]) + elif choice == 1: # a cat walking across the keyboard + idlen = rand.randint(minlen, maxlen) + alph = b"0123456789abcdefghijklmopqrstuvwxyz" + return bytes([rand.choice(alph) for i in range(idlen)]) + else: # a hacker band name idstr = b"" while len(idstr) < minlen: word = rand.choice(wordlist) if idstr != b"": idstr += b"-" - idstr += leetify(word).encode() if randbool() else word.encode() + idstr += leetify(word).encode() + idstr += b"-" + leetify(rand.choice(wordlist)).encode() return idstr[:maxlen] -def fakeids(n: int, havoc: bool = False) -> list[bytes]: - return [fakeid(havoc=havoc) for i in range(n)] +def fakeids(n: int) -> list[bytes]: + return [fakeid() for i in range(n)] def approx_equal(f1: float, f2: float, precision: int = 2) -> bool: @@ -705,8 +711,7 @@ def check_stlinfo( async def test_good_upload( di: DependencyInjector, filetype: str, register: bool ) -> None: - solidname = fakeid(havoc=(filetype == "bin")) # ascii stl cant handle havoc - modelname, authstr = fakeids(2, havoc=True) + solidname, modelname, authstr = fakeids(3) stlfile = genfile(solidname, filetype) ref_info = parse_stlinfo(stlfile) @@ -1025,7 +1030,7 @@ async def havoc_fluff_upload(di: DependencyInjector) -> None: # Simple Upload session = await di.get(Session) if randbool(): - await do_auth(session, fakeid(), check=True, newuser=True); + await do_auth(session, fakeid(), check=True, newuser=True) modelid = await do_upload(session, modelname, stlfile, check=True) assert modelid is not None await check_in_search( diff --git a/do.sh b/do.sh @@ -87,6 +87,20 @@ elif [ "$1" == "ci-test" ]; then elif [ "$1" == "host-socat" ]; then RESULTDIR=service/data/uploads socat -x -v -T180 -s TCP-LISTEN:9090,nodelay,reuseaddr,fork \ EXEC:./run-proxy.sh,raw,pty,echo=0,stderr +elif [ "$1" == "checker-local" ]; then + cd checker + if [ -z "$(docker ps | grep stldoctor-mongo)" ]; then + docker-compose down -v + docker-compose up -d stldoctor-mongo + fi + + export MONGO_ENABLED=1 + export MONGO_HOST=localhost + export MONGO_PORT=27017 + export MONGO_USER=stldoctor_checker + export MONGO_PASSWORD=stldoctor_checker + + python3 -u src/checker.py $@ elif [ "$1" == "host-ncat" ]; then RESULTDIR=service/data/uploads ncat -v -k -l -p 9090 \ -m 200 --no-shutdown -w10s -i180s -c "./run-proxy.sh"