CtrlK
BlogDocsLog inGet started
Tessl Logo

golikovichev/secure-log2test

Turn a Kibana JSON log export into a runnable pytest suite using the secure-log2test CLI. Use when the user has a Kibana or Elasticsearch JSON export of API traffic and wants a regression suite from production logs, when extracting test cases from staging traffic, when scrubbing auth headers or secret-looking body fields before logs leave the laptop, when bridging Kibana-captured requests into a pytest-based suite for CI, when the user mentions Kibana logs, Elasticsearch JSON export, log-to-test conversion, log replay tests, auth header redaction, PII in logs, or regression tests from production traffic.

92

1.00x
Quality

100%

Does it follow best practices?

Impact

93%

1.00x

Average score across 2 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

test_parser.pytests/

import json
from pathlib import Path


from secure_log2test.core.parser import KibanaLogEntry, KibanaLogParser


SAMPLE = Path(__file__).parent.parent / "data" / "sample_kibana_export.json"


def test_parser_reads_sample():
    parser = KibanaLogParser(SAMPLE)
    entries = parser.parse()
    assert len(entries) == 4


def test_method_normalised_to_upper():
    parser = KibanaLogParser(SAMPLE)
    entries = parser.parse()
    methods = {e.method for e in entries}
    assert methods == {"GET", "POST", "PUT", "DELETE"}


def test_status_codes_preserved():
    parser = KibanaLogParser(SAMPLE)
    entries = parser.parse()
    statuses = sorted(e.status for e in entries)
    assert statuses == [200, 201, 204, 404]


def test_skips_malformed_entry(tmp_path):
    bad = tmp_path / "bad.json"
    bad.write_text(
        json.dumps(
            {
                "hits": {
                    "hits": [
                        {"_source": {"method": "GET", "url": "/ok", "status": 200}},
                        {"_source": {"url": "/missing-method", "status": 200}},
                    ]
                }
            }
        )
    )
    parser = KibanaLogParser(bad)
    entries = parser.parse()
    assert len(entries) == 1
    assert entries[0].url == "/ok"


def test_empty_hits(tmp_path):
    empty = tmp_path / "empty.json"
    empty.write_text(json.dumps({"hits": {"hits": []}}))
    parser = KibanaLogParser(empty)
    assert parser.parse() == []


def test_invalid_method_still_normalised():
    entry = KibanaLogEntry(method="get", url="/", status=200)
    assert entry.method == "GET"


def test_default_duration_zero():
    entry = KibanaLogEntry(method="GET", url="/", status=200)
    assert entry.duration == 0

CHANGELOG.md

CONTRIBUTING.md

README.md

REFERENCE.md

RELEASING.md

requirements.txt

SECURITY.md

SKILL.md

tessl.json

tile.json