DevKnife Offline Workbench & Secret-Safe Batch CLI
Zero-upload browser workbench (JWT, JSON/CSV, ReDoS-safe Regex, Diff) paired with a pure-Python batch redaction, NDJSON conversion, and CI diff-gate CLI.
Why this problem wastes time
Every engineering team eventually hits the same quiet security and productivity trap: someone needs to decode a production JWT, flatten an NDJSON export for a stakeholder spreadsheet, or diff two API payloads during an outage. Reaching for a random public web utility means pasting bearer tokens, customer emails, or internal keys into a third-party domain. Even when you use local ad-hoc scripts, four subtle bugs routinely waste hours:
- Corrupted UTF-8 JWT decoding in JavaScript: Calling
atob()directly on a base64url JWT segment mangles non-ASCII characters (likeNguyễnor emoji) becauseatob()emits Latin-1 bytes rather than UTF-8 code points. Worse, many quick decoders silently ignorealg: "none"or forget to testnbf(not-before) clock skew. - Dotted-key collisions and leading-zero mangling in JSON-to-CSV: Flattening
{"a.b": 1, "a": {"b": 2}}without escaping literal dots overwrites one column silently. Going back from CSV to JSON with naiveint()coercion turns zip codes and account IDs like"00123"into123. - Regex tab freezes and zero-width infinite loops: Testing an untrusted pattern like
(a+)+$live in a browser freezes the tab, while running.exec()in awhileloop on.*or^spins forever unlesslastIndexis explicitly incremented on zero-length matches. - Incident logs that lose correlation after redaction: Replacing every token with
"***"scrubs secrets safely, but destroys the ability to tell whether two failing requests used the same expired JWT or two different tokens.
Step-by-step workflow
You can handle deterministic log redaction, UTF-8 JWT inspection, and strict semantic JSON comparisons using only Python's standard library—no pip install required in air-gapped environments or CI runners.
1. Deterministic secret redaction with correlation IDs
By mapping each distinct (secret_type, value) pair to an incremental placeholder like [REDACTED:JWT#1], you keep every secret out of bug reports and LLM prompts while preserving request-to-request correlation:
import re
PATTERNS = [
("PEM_KEY", re.compile(r"-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z0-9 ]*PRIVATE KEY-----")),
("JWT", re.compile(r"\beyJ[A-Za-z0-9_-]{4,}\.eyJ[A-Za-z0-9_-]{4,}\.[A-Za-z0-9_-]*\b")),
("AWS_KEY", re.compile(r"\b(?:AKIA|ASIA)[0-9A-Z]{16}\b")),
]
def scrub_with_correlation(text: str) -> str:
seen, counters = {}, {}
for kind, pat in PATTERNS:
def repl(m, k=kind):
key = (k, m.group(0).strip())
if key not in seen:
counters[k] = counters.get(k, 0) + 1
seen[key] = f"[REDACTED:{k}#{counters[k]}]"
return seen[key]
text = pat.sub(repl, text)
return text
2. Strict semantic JSON diff in CI without Python's 1 == True trap
In Python, {"flag": 1} == {"flag": True} evaluates to True because bool subclasses int. When comparing API fixtures or configuration snapshots in CI, compare type(a) is type(b) recursively while ignoring volatile fields like meta.request_id or timestamp:
def strict_equal(a, b) -> bool:
if type(a) is not type(b):
return False
if isinstance(a, dict):
return a.keys() == b.keys() and all(strict_equal(a[k], b[k]) for k in a)
if isinstance(a, list):
return len(a) == len(b) and all(strict_equal(x, y) for x, y in zip(a, b))
return a == b
3. Safe UTF-8 JWT decoding and clock-skew validation
Always decode base64url segments with TextDecoder("utf-8", { fatal: true }) in JavaScript (or base64.urlsafe_b64decode(...).decode("utf-8") in Python), flag alg: "none" case-insensitively, and explicitly remind operators that offline claim inspection never substitutes for cryptographic signature verification with the issuer's public key.
Common pitfalls & edge cases
- UTF-8 BOM (
\ufeff) in Excel exports: Strip leading BOM characters before parsing CSV headers, or the first column name becomes"\ufeffid"and fails downstream lookups. - Heterogeneous NDJSON streams: Collect the deterministic union of keys across all records before writing the CSV header row so late-appearing fields are never dropped.
- CRLF multi-line PEM blocks: Ensure PEM private-key regexes span
\r\nline endings cleanly on Windows logs. - Zero-width regex guards: Always cap maximum matches and advance
lastIndexwhenmatch[0].length === 0.
Automating it in seconds
Open the Free DevKnife Browser Workbench to run all four tools—UTF-8 JWT Inspector, Nested JSON-to-CSV Flattener, ReDoS-Guarded Regex Tester, and Line Diff Viewer—100% locally in your browser with zero uploads.
When you need automated offline pipelines, the $5.00 DevKnife Pro CLI Kit packages devknife.py (zero-dependency Python 3.10+), sample fixtures, and test_devknife.py:
- Free Browser Workbench: Interactive single-payload JWT decode, JSON/NDJSON↔CSV conversion, ReDoS-safe regex testing, and 2,000-line browser diff.
- $5.00 Pro CLI Kit: Batch folder/NDJSON processing (
json2csv/csv2json), deterministic secret redaction with--reportand CI--checkexit code2(redact), batchjwt-audit --warn-days --fail-on-error, anddiff --json-semantic --ignore-keys --ignore-paths --fail-on-diff.