diff options
| author | Louis Burda <quent.burda@gmail.com> | 2021-07-09 02:21:28 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2021-07-09 02:21:28 +0200 |
| commit | bc05a77222267eeb4fdc6229d2f34c883ba7c056 (patch) | |
| tree | e1f88d72d3f1aea90f58c0fab755aebf3f526b8a /checker | |
| parent | 3d0e670b1c6d24036007c6e4d3419468170eb6c3 (diff) | |
| download | enowars5-service-stldoctor-bc05a77222267eeb4fdc6229d2f34c883ba7c056.tar.gz enowars5-service-stldoctor-bc05a77222267eeb4fdc6229d2f34c883ba7c056.zip | |
moved local check start out of checker folder, merged havocids into fakeid and created extra type of id which is only lower alphanumeric
Diffstat (limited to 'checker')
| -rw-r--r-- | checker/local.sh | 14 | ||||
| -rw-r--r-- | checker/src/checker.py | 25 |
2 files changed, 15 insertions, 24 deletions
diff --git a/checker/local.sh b/checker/local.sh deleted file mode 100644 index 713bea0..0000000 --- a/checker/local.sh +++ /dev/null @@ -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 index 7387aa9..54820ee 100644 --- 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( |
