Skip to content

Python SDK a CLI

Balík aether365 je oficiálne Python SDK a rozhranie príkazového riadka pre Aether365 API. Obaľuje https://api.aether365.io, rieši autentifikáciu, rozbaľuje obálku odpovede a prechodné zlyhania automaticky opakuje. Všetko, čo zvládnete cez curl, zvládnete aj cez SDK alebo CLI.

SDK aj CLI používajú API kľúč (ak_live_...) a smerujú na zjednotený endpoint - požiadavky sa automaticky presmerujú do domovského regiónu vášho tenanta. Ako kľúče fungujú, opisuje stránka Autentifikácia.

Inštalácia

Balík sa distribuuje interne (nie je na PyPI). Nainštalujte ho priamo z repozitára alebo z lokálneho checkoutu.

bash
# From a local checkout of the monorepo
pip install ./packages/cli

# Or with Poetry, from a path
poetry add ./packages/cli

Vyžaduje sa Python 3.12 alebo novší. Inštalácia balíka zároveň pridá príkaz aether365 do PATH.

Konfigurácia

SDK aj CLI čítajú rovnaké premenné prostredia:

PremennáÚčelPredvolené
AETHER365_API_KEYVáš API kľúč (ak_live_...). Povinné.-
AETHER365_API_URLPrepísanie základnej URL (napríklad dev endpoint).https://api.aether365.io
AETHER365_OUTPUTVýstupný formát CLI: table alebo json.table
bash
export AETHER365_API_KEY="ak_live_..."

Región je automatický: API podľa kľúča určí vášho tenanta a požiadavku odovzdá do správneho regiónu, takže región nikdy nekonfigurujete ani neposielate.

Rýchly štart: SDK

python
from aether365 import Aether365Client

with Aether365Client() as client:          # reads AETHER365_API_KEY
    tenant = client.tenants.me()
    print(tenant["name"])

    # Trigger a scan and wait for it to finish
    scan = client.scans.create("compliance")
    for snapshot in client.scans.wait(scan["id"]):
        print(snapshot["status"])

    # Read the findings
    findings = client.scans.results(scan["id"], result="Failed")
    print(f"{len(findings)} failed checks")

Rýchly štart: CLI

bash
# Show the authenticated tenant
aether365 tenant me

# Trigger a scan and follow progress until it finishes
aether365 scan run --type compliance --watch

# List scans as JSON
aether365 --output json scan list

# Fail a CI job when a scan has failed findings (exit code 2)
aether365 scan results <SCAN_ID> --fail-on-findings

Čo API kľúč môže a čo nemôže

API kľúč je obmedzený na bezpečnú plochu: čítanie plus prevádzkové operácie. Môže čítať vaše dáta, spúšťať a spravovať skeny, generovať reporty a spravovať ciele attack surface. Nemôže vykonávať akcie ovládajúce účet ani akcie, ktoré by mohli uzamknúť adresár - správu API kľúčov, fakturáciu, členstvo v tíme, pripájanie a odpájanie connectionov, SSO, aplikovanie remediačného plánu ani zápisy AI Pilota do conditional access / break-glass. Tie zostávajú dostupné len prihlásenej relácii v dashboarde. Požiadavka na nepovolenú cestu vracia 403 AUTH_INSUFFICIENT_SCOPE.

Prehľad príkazov a metód

Každý riadok ukazuje tú istú operáciu tromi spôsobmi: čistý curl, metóda SDK a príkaz CLI.

Tenant a účet

OperáciacurlSDKCLI
Profil tenantaGET /tenants/meclient.tenants.me()aether365 tenant me
Zoznam pripojeníGET /tenants/me/connectionsclient.connections.list()aether365 tenant connections
Predvoľby notifikáciíGET /tenants/me/notificationsclient.notifications.get()aether365 tenant notifications
Naplánované skenyGET /tenants/me/scheduled-scansclient.scheduled_scans.list()aether365 tenant scheduled-scans

Skeny

OperáciacurlSDKCLI
Zoznam skenovGET /tenants/me/scansclient.scans.list()aether365 scan list
Spustenie skenuPOST /tenants/me/scansclient.scans.create("compliance")aether365 scan run --type compliance
Načítanie skenuGET /scans/{id}client.scans.get(id)aether365 scan get <id>
Čítanie výsledkovGET /scans/{id}/resultsclient.scans.results(id)aether365 scan results <id>
Zrušenie skenuPOST /scans/{id}/cancelclient.scans.cancel(id)aether365 scan cancel <id>
Skrytie skenuPATCH /scans/{id}/hideclient.scans.hide(id)aether365 scan hide <id>
Zrušenie skrytia skenuPATCH /scans/{id}/unhideclient.scans.unhide(id)aether365 scan unhide <id>
Zmazanie skenuDELETE /scans/{id}client.scans.delete(id)aether365 scan delete <id>

curl na spustenie skenu:

bash
curl -X POST https://api.aether365.io/tenants/me/scans \
  -H "Authorization: Bearer $AETHER365_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scanType": "compliance"}'

Reporty

OperáciacurlSDKCLI
Stav reportuGET /scans/{id}/reportclient.reports.status(id)aether365 report status <id>
Vygenerovanie reportuPOST /scans/{id}/report/generateclient.reports.generate(id)aether365 report generate <id>
Zoznam reportovGET /tenants/me/reportsclient.reports.list()aether365 report list
Stiahnutie reportuGET /scans/{id}/report (presigned)client.reports.download(id, path)aether365 report download <id> -o out.pdf

Stav reportu je jedna z hodnôt ready, rendering, orgNameRequired alebo locked. Vygenerovanie reportu môže spotrebovať reportový kredit (jednorazový poplatok, keď plán nezahŕňa žiadny kredit) - vlastník kľúča s tým súhlasí tým, že zavolá generate.

Výpis reportov je stránkovaný offsetom: hodnotu meta["nextCursor"] (celočíselný offset riadka, alebo None na poslednej stránke) pošlite späť ako cursor. client.reports.iter_all() kurzor sleduje za vás.

Attack surface

OperáciacurlSDKCLI
PrehľadGET /tenants/me/attack-surfaceclient.attack_surface.summary()aether365 eas summary
HistóriaGET /tenants/me/attack-surface/historyclient.attack_surface.history()aether365 eas history
Zoznam cieľovGET /tenants/me/attack-surface/targetsclient.attack_surface.targets()aether365 eas targets list
Pridanie cieľaPOST /tenants/me/attack-surface/targetsclient.attack_surface.add_target(host)aether365 eas targets add <host>
Aktualizácia cieľaPATCH /tenants/me/attack-surface/targets/{id}client.attack_surface.update_target(id, ...)aether365 eas targets update <id> --label ...
Zmazanie cieľaDELETE /tenants/me/attack-surface/targets/{id}client.attack_surface.remove_target(id)aether365 eas targets remove <id>
Overenie cieľaPOST /tenants/me/attack-surface/targets/{id}/verifyclient.attack_surface.verify_target(id)aether365 eas targets verify <id>
Spustenie EAS skenuPOST /tenants/me/attack-surface/scanclient.attack_surface.scan()aether365 eas scan

Bezpečnostný postoj, remediácia a AI Pilot

OperáciacurlSDKCLI
Pohľad na hrozby a rizikáGET /tenants/me/threatsclient.threats.list()aether365 threats
Stav politíkGET /tenants/me/policiesclient.policies.list()aether365 policies
Remediačné schopnostiGET /tenants/me/remediation/capabilitiesclient.remediation.capabilities()aether365 remediation capabilities
Zoznam remediačných plánovGET /tenants/me/remediation-plansclient.remediation.plans()aether365 remediation plans
Načítanie remediačného plánuGET /tenants/me/remediation-plans/{id}client.remediation.plan(id)aether365 remediation plan <id>
AI Pilot: remediovateľné položkyGET /tenants/me/ai-pilot/remediableclient.ai_pilot.remediable()aether365 ai-pilot remediable
AI Pilot: break-glass účtyGET /tenants/me/ai-pilot/break-glassclient.ai_pilot.break_glass()aether365 ai-pilot break-glass
AI Pilot: CA politikyGET /tenants/me/ai-pilot/conditional-accessclient.ai_pilot.conditional_access()aether365 ai-pilot conditional-access

Remediácia je pre API kľúče iba na čítanie. Aplikovanie plánu nie je sprístupnené: položky plánu z registra akcií môžu obsahovať úpravy Conditional Access / authorization policy, ktoré by tenanta zamkli mimo jeho vlastného adresára (AADSTS50097), takže apply zostáva v dashboarde s operátorom v slučke. Z rovnakého dôvodu sú conditional-access a break-glass v AI Pilote takisto len na čítanie.

Spracovanie chýb a opakovanie

Každá chyba API sa mapuje na typovanú výnimku odvodenú od Aether365Error:

python
from aether365 import Aether365Client
from aether365.exceptions import PermissionError_, PlanLimitError, NotFoundError

with Aether365Client() as client:
    try:
        client.scans.create("compliance")
    except PlanLimitError:
        print("Scan quota reached for this plan.")
    except PermissionError_:
        print("Route not allowed for this key, or plan lacks API access.")
    except NotFoundError:
        print("Resource not found.")

Klient automaticky opakuje 429 RATE_LIMITED a 503 SERVICE_STARTING (zahrievanie studenej databázy v dev prostredí) s exponenciálnym backoffom a rešpektuje hlavičku Retry-After. Chyby kvót ako SCAN_PLAN_LIMIT_REACHED sa vyhadzujú okamžite - neopakujú sa.

Použitie CLI v CI

aether365 scan results <id> --fail-on-findings skončí s kódom 2, keď existuje akýkoľvek neúspešný nález, takže pipeline môže výsledky skenu použiť ako bránu:

bash
aether365 scan run --type compliance --watch
aether365 scan results "$SCAN_ID" --fail-on-findings

CLI vypisuje chyby na stderr a končí kódom 1 pri akejkoľvek chybe API a kódom 2 na bráne nálezov.

Bola táto stránka užitočná?