Skip to main content

liveapisec — CLI/SDK do LiveAPISec Developer API

Oficjalny, cienki klient do LiveAPISec Developer API. Instalujesz raz, używasz w dowolnym projekcie, skrypcie i pipeline CI/CD — bez dashboardu i bez curl.

Kiedy to jest? Zamiast ręcznie przechodzić kreatora w panelu, developer pushuje endpointy + opcjonalny token z swojego środowiska (CI/CD, agent, skrypt). Token jest generowany u Ciebie i szyfrowany po stronie serwera (AES-256). Tip: brak tokena = testujemy tylko to, co publiczne.


Instalacja

Z GitHub (rekomendowane, zanim trafimy na PyPI):

pip install "liveapisec @ git+https://github.com/LiveApiSec/liveapisec.git"

Po publikacji na PyPI:

pip install liveapisec

Sprawdź:

liveapisec --help

Kiedy zainstalujesz raz (np. w obrazie CI, na maszynie dev, w GitHub Actions) — komenda liveapisec jest dostępna w każdym projekcie w tej maszynie.


Konfiguracja

Klucz API generujesz raz w panelu: Settings → Developer API → Create API key (klucz las_dev_... pokazywany jest tylko raz — trzymaj go jako secret).

export LIVEAPISEC_API_KEY=las_dev_...          # wymagane
export LIVEAPISEC_API_URL=https://liveapisec.com   # opcjonalne (domyślne)

Można też podać per-komenda: --api-key / --api-url.


Komendy

1. push — wyślij API (idempotentne, bezpieczne w CI)

liveapisec push \
  --name my-api \
  --base-url https://api.example.com \
  --endpoint "GET /users" \
  --endpoint "POST /payments"
  • Ten sam name + base_url = ten sam site (aktualizacja, nie duplikat) — możesz wołać push w każdym buildzie.
  • Zamiast listy endpointów możesz podać OpenAPI: --openapi-url https://api.example.com/openapi.json.
  • Opcjonalny token: --auth-type jwt --auth-token <TOKEN> (albo bearer, cookie --auth-cookie "session=...", api_key --auth-header X-API-Key).

Wynik:

site 65f...abc: my-api — 2 endpoints, auth=none
export SITE_ID=65f...abc

2. scan — odpal test bezpieczeństwa

# zwykłe odpalanie (202, nie czeka)
liveapisec scan --site SITE_ID --branch main --commit "$GITHUB_SHA"

# czekaj na wynik i próg błędu dla CI (gate)
liveapisec scan --site SITE_ID --branch main --commit "$SHA" \
  --wait --fail-on high
  • --wait — polluje aż skan się zakończy (domyślnie timeout 600 s, interwał 3 s; zmiana przez --timeout / --poll-interval).
  • --fail-on highexit code 1 gdy znajdzie finding severity high/critical; --fail-on critical tylko przy krytycznych; pomiń → zawsze exit 0 (poza błędami).

3. status — stan site'a i ostatnich skanów

liveapisec status --site SITE_ID

4. findings — wyniki skanu

liveapisec findings --site SITE_ID --scan SCAN_ID
liveapisec findings --site SITE_ID --scan SCAN_ID --json   # surowe dane (dla agenta/AI)

5. sites — szczegóły site'a

liveapisec sites --site SITE_ID

GitHub Actions — pełny przykład (gate na push)

name: liveapisec
on: push
jobs:
  security-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with: { python-version: "3.12" }
      - name: Install CLI
        run: pip install "liveapisec @ git+https://github.com/LiveApiSec/liveapisec.git"
      - name: Push API + run security test (gate on high)
        env:
          LIVEAPISEC_API_KEY: ${{ secrets.LIVEAPISEC_KEY }}
        run: |
          liveapisec push --name my-api --base-url "$BASE_URL" \
            --endpoint "GET /users" --endpoint "POST /payments"
          liveapisec scan --site "$SITE_ID" \
            --branch "${GITHUB_REF#refs/heads/}" --commit "$GITHUB_SHA" \
            --wait --fail-on high

Dlaczego push jest bezpieczny? Push jest idempotentny (name+base_url → ten sam site), więc kolejny build nie tworzy śmieci — aktualizuje endpointy i token, a następny scan testuje najnowszy stan.


Exit codes

Code Znaczenie
0 OK (brak findings ≥ progu, lub bez --fail-on)
1 Gate failed — znaleziono findings ≥ --fail-on
2 Błąd użycia / błąd API / brak klucza

Rozwój / testy

pip install -e ./cli[dev]
cd cli && python -m pytest tests/ -q

API (SDK)

Poza CLI pakiet eksportuje też klienta do skryptów:

from liveapisec import LiveAPISec

api = LiveAPISec()  # LIVEAPISEC_API_KEY z env
site = api.create_site("my-api", "https://api.example.com",
                       endpoints=[{"method": "GET", "path": "/users"}])
scan = api.trigger_scan(site["site_id"], branch="main", commit="abc")
done = api.wait_for_scan(site["site_id"], scan["scan_id"])
blocked = LiveAPISec.findings_above(done["findings"], "high")

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

liveapisec-0.1.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

liveapisec-0.1.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file liveapisec-0.1.0.tar.gz.

File metadata

  • Download URL: liveapisec-0.1.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for liveapisec-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0202ca314b9abaaa24cb9d8c2f7d04e77f7e2d2d082a2960f57aec4df37fc3f6
MD5 98f7d28b998436c0fba48d6e48cd31e5
BLAKE2b-256 6aa076cdd34fc7a0833af0641246adde75916e41c23a42d0b0e662a6b5aa237e

See more details on using hashes here.

File details

Details for the file liveapisec-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: liveapisec-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for liveapisec-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 848b7769e41a02c601746d1758f8ccf6d53939085e447a9a543907d8622782cb
MD5 a426e4833a722b13601a4fc990835eb3
BLAKE2b-256 dafde9dd1447343b3ddeb6cf017c8f73b2d3cbc244e5bd82c7a56630ddb7e491

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page