apex-twin 1.19.0: ESP app info, API auth and cache audits, log timeline
Hardware: - esp_app_info: app image header (magic 0xE9, segment count, entry) and the esp_app_desc_t at 0x20 (magic 0xABCD5432): version, project name, build time/date, IDF version and ELF SHA-256; offset can point at an OTA partition. Red: - api_auth_audit: unauthenticated GETs over an endpoint list, reporting status, size, 2xx vs 401/403, JSON content type, evidence for open responses. - cache_audit: clean vs parameterized URL, comparing Cache-Control/Pragma/Age/ Vary/X-Cache; flags parameterized-cacheable and missing Vary. Blue: - log_timeline: normalises auth and access log timestamps (auth gets the current year), merges and sorts them and returns the first N entries with source tags; paths limited to /var/log and the state dir. Tests with an app image, API/cache HTTP fixtures and two log files. 686 checks, ASan suite green, analyze clean, release-check green including distcheck 1.19.0.
This commit is contained in:
1 parent
d966fa9600
commit
5392f911d1
10 files changed
+757
-15
No files matched your search
+20
-1
@@ -8,7 +8,26 @@ fields, and state from an older version is read by a newer one.
|
||||
There are no git tags. The hash next to a version is the commit that introduced
|
||||
it; the current entry is the commit that adds this section.
|
||||
|
||||
## 1.18.0 — 2026-11-21 — this change
|
||||
## 1.19.0 — 2026-11-21 — this change
|
||||
|
||||
- **ESP app** (`esp_app_info`): parses an app image header (magic 0xE9,
|
||||
segment count, entry address) and the `esp_app_desc_t` at 0x20 (magic
|
||||
0xABCD5432): version, project name, build time/date, IDF version and ELF
|
||||
SHA-256. The offset can point at an OTA partition in a full dump.
|
||||
- **API auth** (`api_auth_audit`): GETs a caller-supplied endpoint list without
|
||||
credentials and reports status, size, 2xx vs 401/403, JSON content type and
|
||||
saves open responses as evidence.
|
||||
- **Cache** (`cache_audit`): fetches a path clean and with a marker parameter,
|
||||
compares Cache-Control/Pragma/Age/Vary/X-Cache and flags a cacheable
|
||||
parameterized response and a cacheable response without Vary.
|
||||
- **Blue** (`log_timeline`): normalises auth-log and access-log timestamps to
|
||||
YYYYMMDDHHMMSS (current year for auth), merges and sorts them, returns the
|
||||
first N entries with source tags; paths limited to /var/log and the state
|
||||
dir.
|
||||
- Tests with an app image, API/cache HTTP fixtures and two log files. 686
|
||||
checks. Coverage 79.9%.
|
||||
|
||||
## 1.18.0 — 2026-11-21 — d966fa9
|
||||
|
||||
- **RPC** (`rpc_probe`): one ONC RPC CALL to the portmapper (program 100000,
|
||||
version 2, procedure DUMP) with a hand-built XDR message; decodes the
|
||||
|
||||
@@ -5,11 +5,11 @@ no Python in the serving path. It gives an agent real reconnaissance and real we
|
||||
testing behind a scope gate that refuses everything until a rules-of-engagement
|
||||
file says otherwise.
|
||||
|
||||
**120 tools · 674 end-to-end checks · 340 fuzz cases · 79.7% line coverage · ~531 KiB**
|
||||
**124 tools · 686 end-to-end checks · 340 fuzz cases · 79.9% line coverage · ~539 KiB**
|
||||
|
||||
```
|
||||
$ ./apex-twin --check
|
||||
{"version":"1.18.0","tools":120,...,"scope":{"loaded":true,...}}
|
||||
{"version":"1.19.0","tools":124,...,"scope":{"loaded":true,...}}
|
||||
```
|
||||
|
||||
APEX TWIN was inspired by [ARTEX](https://github.com/Autumn-27/artex) (scope
|
||||
@@ -149,7 +149,7 @@ closes a request whose head or body does not arrive within
|
||||
|
||||
---
|
||||
|
||||
## Tools (120)
|
||||
## Tools (124)
|
||||
|
||||
### Scope and bookkeeping
|
||||
|
||||
@@ -276,6 +276,8 @@ command in the allowlist: a receiver is a scanner, a transmitter is an attack.
|
||||
| `csrf_audit` | Forms on one page: action, method, input count and missing CSRF token fields |
|
||||
| `rpc_probe` | ONC RPC portmapper DUMP: program/version/protocol/port mappings with service names |
|
||||
| `ntp_probe` | NTPv4 client packet: version, mode, leap, stratum, refid, root delay/dispersion, time |
|
||||
| `api_auth_audit` | Unauthenticated GETs over an endpoint list: status, JSON, open vs 401/403, evidence |
|
||||
| `cache_audit` | Clean vs parameterized URL: Cache-Control/Age/Vary/X-Cache, parameterized-cacheable finding |
|
||||
| `imap_probe` | Banner, CAPABILITY list, STARTTLS and LOGINDISABLED; no LOGIN |
|
||||
| `pop3_probe` | Banner, CAPA list, STLS flag; no USER/PASS |
|
||||
| `sip_probe` | One UDP OPTIONS: status line, Server header, Allow methods |
|
||||
@@ -319,6 +321,7 @@ command in the allowlist: a receiver is a scanner, a transmitter is an attack.
|
||||
| `auditd_audit` | auditd type counts, AVC denials, failed auth, top exe paths and keys |
|
||||
| `ssh_config_audit` | sshd_config scoring: root login, passwords, tunnels, forwardings, legacy ciphers/MACs/kex |
|
||||
| `pam_audit` | pam.d: pam_permit, pam_unix nullok, pam_exec and missing faillock/tally lockout |
|
||||
| `log_timeline` | Merge auth and access logs into one sorted chronology with source tags |
|
||||
|
||||
### ESP32
|
||||
|
||||
@@ -331,6 +334,7 @@ command in the allowlist: a receiver is a scanner, a transmitter is an attack.
|
||||
| `esp_partition_table` | Parse a flash dump's partition table at 0x8000 (0xAA50 entries, MD5 entry) |
|
||||
| `esp_nvs_parse` | Parse an NVS partition dump: namespaces, keys, types, spans |
|
||||
| `firmware_scan` | Signatures (ESP app, partition table, NVS, filesystems, PEM), 4 KiB entropy, strings |
|
||||
| `esp_app_info` | App header and esp_app_desc_t: version, project, build date, IDF version, ELF hash |
|
||||
|
||||
### Method
|
||||
|
||||
@@ -536,6 +540,8 @@ The full threat model, trust boundaries and a hardening checklist are in
|
||||
| auditd | 5000 lines; path limited to /var/log or the state dir |
|
||||
| RPC/NTP | one UDP query, two attempts, 2 s wait |
|
||||
| sshd/PAM | read config files only; optional root prefix |
|
||||
| API/cache | one GET per endpoint, two for cache_audit |
|
||||
| Log timeline | 200 entries from up to 5000 lines per log |
|
||||
|
||||
---
|
||||
|
||||
@@ -546,7 +552,7 @@ Flags are fixed: `-std=c99 -Wall -Wextra -Wpedantic -Werror` plus
|
||||
|
||||
```sh
|
||||
make # apex-twin
|
||||
make test # version check + gate audit + 674 end-to-end checks
|
||||
make test # version check + gate audit + 686 end-to-end checks
|
||||
make version-check # the five places that carry a version must agree
|
||||
make gate-audit # static: every target-taking tool calls the gate
|
||||
make asan # apex-twin-asan with ASan + UBSan
|
||||
@@ -656,7 +662,7 @@ src/tools_red.c vuln_check, subdomain_enum, cred_test, vhost_discovery,
|
||||
elasticsearch_probe, imap_probe, pop3_probe, sip_probe,
|
||||
telnet_probe, http_methods, websocket_probe, ike_probe,
|
||||
snmp_walk, ldap_search, openapi_discovery, csrf_audit,
|
||||
rpc_probe, ntp_probe
|
||||
rpc_probe, ntp_probe, api_auth_audit, cache_audit
|
||||
src/tools_blue.c hardening_audit, log_audit, ioc_scan, web_log_audit,
|
||||
detect_rules, integrity_baseline, mitre_map,
|
||||
process_snapshot, persistence_audit, net_baseline,
|
||||
@@ -664,7 +670,8 @@ src/tools_blue.c hardening_audit, log_audit, ioc_scan, web_log_audit,
|
||||
package_integrity, mount_audit, firewall_audit,
|
||||
systemd_audit
|
||||
src/tools_esp.c esp_info, esp_monitor, esp_read_flash, esp_flash,
|
||||
esp_partition_table, esp_nvs_parse, firmware_scan
|
||||
esp_partition_table, esp_nvs_parse, firmware_scan,
|
||||
esp_app_info
|
||||
src/tools_proto.c ftp_probe, smtp_probe, ssh_audit, tls_audit,
|
||||
redis_probe, snmp_probe, dns_zone_transfer
|
||||
src/tools_db.c mysql_probe, postgres_probe, mongo_probe,
|
||||
@@ -698,7 +705,7 @@ examples/ scope.json
|
||||
|
||||
## Status
|
||||
|
||||
1.18.0. Built and run: 120 tools, 674 checks, 340 fuzz cases and 79.7% line
|
||||
1.19.0. Built and run: 124 tools, 686 checks, 340 fuzz cases and 79.9% line
|
||||
coverage. The loop closes: a probe captures the exchange as a pair, a finding
|
||||
points at it, `finding_update` gives it a state, an asset records the host it
|
||||
came from, `cors_check`/`cookie_audit`/`http_options` turn a web answer into a
|
||||
@@ -734,7 +741,8 @@ audit; 1.15 added HTTP method, WebSocket and IKEv2 checks plus a firewall audit;
|
||||
added SNMP walk, LDAP search and OpenAPI discovery plus a systemd audit; 1.17
|
||||
added CSRF, kernel, sudoers and auditd checks and fixed evidence ordering for
|
||||
same-second files; 1.18 added RPC and NTP probes plus sshd_config and PAM
|
||||
audits, again without changing an existing file format.
|
||||
audits; 1.19 added ESP app parsing, API auth and cache audits plus a log
|
||||
timeline, again without changing an existing file format.
|
||||
|
||||
Not yet wired into a fleet router, and there is no TLS interception.
|
||||
|
||||
|
||||
+4
-1
@@ -9,7 +9,7 @@ problem.
|
||||
|
||||
The supported line is the one printed by `apex-twin --version` for the tree you
|
||||
built; this document ships with that same tree. At the time of writing the line
|
||||
is **1.18.x** (`src/apex.h`, `APEX_VERSION`). Security fixes land on the current
|
||||
is **1.19.x** (`src/apex.h`, `APEX_VERSION`). Security fixes land on the current
|
||||
line. The 1.0 line promises that the on-disk JSON formats for findings, assets
|
||||
and traffic only gain fields, so state stays readable; older builds are still
|
||||
rebuilt rather than patched in place.
|
||||
@@ -66,6 +66,9 @@ only narrow what the proxy does (the scope gate still runs first).
|
||||
- **Firmware writing needs an explicit confirmation.** `esp_flash` refuses
|
||||
without `confirm=true`, validates an absolute image path and audits the
|
||||
attempt; it exists to provision the operator's own board.
|
||||
- **API and cache probes are unauthenticated GETs.** `api_auth_audit` requests
|
||||
a caller-supplied endpoint list without credentials, `cache_audit` fetches a
|
||||
path twice, and `log_timeline` merges two local logs (restricted paths).
|
||||
- **RPC and NTP are single queries.** `rpc_probe` sends one portmapper DUMP and
|
||||
`ntp_probe` one client packet; neither mounts an export, changes a clock or
|
||||
requests a monlist. `ssh_config_audit` and `pam_audit` read config files.
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
.\" apex-twin.1 - manual page for APEX TWIN
|
||||
.TH APEX-TWIN 1 "2026-11-21" "apex-twin 1.18.0" "User Commands"
|
||||
.TH APEX-TWIN 1 "2026-11-21" "apex-twin 1.19.0" "User Commands"
|
||||
.SH NAME
|
||||
apex-twin \- scope\-gated offensive\-security MCP server
|
||||
.SH SYNOPSIS
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "mcp.h"
|
||||
|
||||
#define APEX_VERSION "1.18.0"
|
||||
#define APEX_VERSION "1.19.0"
|
||||
#define APEX_MAX_OUT (1u << 20)
|
||||
#define APEX_PATH_MAX 512
|
||||
#define APEX_PATH_FULL 1024
|
||||
|
||||
@@ -4588,6 +4588,189 @@ static void t_pam_audit(mcp_conn *c, const mcp_json *args, void *user)
|
||||
mcp_buf_free(&findings);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- log_timeline */
|
||||
|
||||
typedef struct {
|
||||
char key[24];
|
||||
char source[12];
|
||||
char line[240];
|
||||
} tl_entry;
|
||||
|
||||
typedef struct {
|
||||
tl_entry *entries;
|
||||
int count;
|
||||
int max;
|
||||
} tl_ctx;
|
||||
|
||||
static int tl_month(const char *name)
|
||||
{
|
||||
static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May",
|
||||
"Jun", "Jul", "Aug", "Sep", "Oct",
|
||||
"Nov", "Dec" };
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 12; i++)
|
||||
if (strncasecmp(name, months[i], 3) == 0)
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int tl_key_auth(const char *line, int year, char *key, size_t n)
|
||||
{
|
||||
char mon[8];
|
||||
int day;
|
||||
int h;
|
||||
int mi;
|
||||
int sec;
|
||||
int m;
|
||||
|
||||
if (sscanf(line, "%7s %d %d:%d:%d", mon, &day, &h, &mi, &sec) != 5)
|
||||
return 0;
|
||||
m = tl_month(mon);
|
||||
if (m < 0 || day < 1 || day > 31)
|
||||
return 0;
|
||||
snprintf(key, n, "%04d%02d%02d%02d%02d%02d", year, m + 1, day, h, mi,
|
||||
sec);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int tl_key_access(const char *line, char *key, size_t n)
|
||||
{
|
||||
const char *p = strchr(line, '[');
|
||||
char mon[8];
|
||||
int day;
|
||||
int year;
|
||||
int h;
|
||||
int mi;
|
||||
int sec;
|
||||
int m;
|
||||
|
||||
if (p == NULL)
|
||||
return 0;
|
||||
if (sscanf(p + 1, "%d/%3s/%d:%d:%d:%d", &day, mon, &year, &h, &mi,
|
||||
&sec) != 6)
|
||||
return 0;
|
||||
m = tl_month(mon);
|
||||
if (m < 0)
|
||||
return 0;
|
||||
snprintf(key, n, "%04d%02d%02d%02d%02d%02d", year, m + 1, day, h, mi,
|
||||
sec);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void tl_add(tl_ctx *ctx, const char *key, const char *source,
|
||||
const char *line)
|
||||
{
|
||||
size_t w = 0;
|
||||
|
||||
if (ctx->count >= ctx->max)
|
||||
return;
|
||||
snprintf(ctx->entries[ctx->count].key,
|
||||
sizeof(ctx->entries[0].key), "%s", key);
|
||||
snprintf(ctx->entries[ctx->count].source,
|
||||
sizeof(ctx->entries[0].source), "%s", source);
|
||||
while (line[w] != '\0' && line[w] != '\n' && line[w] != '\r' &&
|
||||
w + 1 < sizeof(ctx->entries[0].line)) {
|
||||
char ch = line[w];
|
||||
|
||||
if ((unsigned char)ch < 0x20)
|
||||
ch = ' ';
|
||||
ctx->entries[ctx->count].line[w] = ch;
|
||||
w++;
|
||||
}
|
||||
ctx->entries[ctx->count].line[w] = '\0';
|
||||
ctx->count++;
|
||||
}
|
||||
|
||||
static void tl_read(tl_ctx *ctx, const char *path, int access, int year)
|
||||
{
|
||||
FILE *f = fopen(path, "rb");
|
||||
char *line = NULL;
|
||||
size_t cap = 0;
|
||||
int lines = 0;
|
||||
|
||||
if (f == NULL)
|
||||
return;
|
||||
while (lines < 5000 && getline(&line, &cap, f) >= 0) {
|
||||
char key[24];
|
||||
|
||||
lines++;
|
||||
if (access ? tl_key_access(line, key, sizeof(key))
|
||||
: tl_key_auth(line, year, key, sizeof(key)))
|
||||
tl_add(ctx, key, access ? "access" : "auth", line);
|
||||
}
|
||||
free(line);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
static int tl_cmp(const void *a, const void *b)
|
||||
{
|
||||
const tl_entry *x = a;
|
||||
const tl_entry *y = b;
|
||||
int c = strcmp(x->key, y->key);
|
||||
|
||||
if (c != 0)
|
||||
return c;
|
||||
return strcmp(x->source, y->source);
|
||||
}
|
||||
|
||||
static void t_log_timeline(mcp_conn *c, const mcp_json *args, void *user)
|
||||
{
|
||||
const char *auth_path = mcp_arg_string(args, "auth");
|
||||
const char *access_path = mcp_arg_string(args, "access");
|
||||
int limit = mcp_arg_int(args, "limit", 200);
|
||||
tl_ctx ctx;
|
||||
time_t now = time(NULL);
|
||||
struct tm tmv = *gmtime(&now);
|
||||
mcp_buf b;
|
||||
int i;
|
||||
|
||||
(void)user;
|
||||
if (auth_path == NULL || *auth_path == '\0')
|
||||
auth_path = "/var/log/auth.log";
|
||||
if (access_path == NULL || *access_path == '\0')
|
||||
access_path = "/var/log/nginx/access.log";
|
||||
if (!allowed_log_path(auth_path) || !allowed_log_path(access_path)) {
|
||||
mcp_reply_error(c, "paths must be under /var/log/ or the state dir");
|
||||
return;
|
||||
}
|
||||
if (limit <= 0 || limit > 1000)
|
||||
limit = 200;
|
||||
memset(&ctx, 0, sizeof(ctx));
|
||||
ctx.max = 2000;
|
||||
ctx.entries = calloc((size_t)ctx.max, sizeof(*ctx.entries));
|
||||
if (ctx.entries == NULL) {
|
||||
mcp_reply_error(c, "out of memory");
|
||||
return;
|
||||
}
|
||||
tl_read(&ctx, auth_path, 0, tmv.tm_year + 1900);
|
||||
tl_read(&ctx, access_path, 1, tmv.tm_year + 1900);
|
||||
qsort(ctx.entries, (size_t)ctx.count, sizeof(*ctx.entries), tl_cmp);
|
||||
if (ctx.count > limit)
|
||||
ctx.count = limit;
|
||||
mcp_buf_init(&b);
|
||||
mcp_buf_puts(&b, "{\"auth\":");
|
||||
apex_json_str(&b, auth_path);
|
||||
mcp_buf_puts(&b, ",\"access\":");
|
||||
apex_json_str(&b, access_path);
|
||||
mcp_buf_printf(&b, ",\"count\":%d,\"entries\":[", ctx.count);
|
||||
for (i = 0; i < ctx.count; i++) {
|
||||
if (i > 0)
|
||||
mcp_buf_puts(&b, ",");
|
||||
mcp_buf_puts(&b, "{\"time\":");
|
||||
apex_json_str(&b, ctx.entries[i].key);
|
||||
mcp_buf_puts(&b, ",\"source\":");
|
||||
apex_json_str(&b, ctx.entries[i].source);
|
||||
mcp_buf_puts(&b, ",\"line\":");
|
||||
apex_json_str(&b, ctx.entries[i].line);
|
||||
mcp_buf_puts(&b, "}");
|
||||
}
|
||||
mcp_buf_puts(&b, "]}");
|
||||
mcp_reply_json(c, b.p);
|
||||
mcp_buf_free(&b);
|
||||
free(ctx.entries);
|
||||
}
|
||||
|
||||
const mcp_tool TOOLS_BLUE[] = {
|
||||
{ "hardening_audit",
|
||||
"Read-only posture audit of the local host: sshd_config (root login, "
|
||||
@@ -4859,6 +5042,19 @@ const mcp_tool TOOLS_BLUE[] = {
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
|
||||
t_pam_audit },
|
||||
{ "log_timeline",
|
||||
"Merge an auth log and an access log into one chronology: both timestamps "
|
||||
"are normalised to YYYYMMDDHHMMSS (auth lines get the current year), the "
|
||||
"combined list is sorted and the first N entries are returned with their "
|
||||
"source. Paths are limited to /var/log and the state dir. Read-only.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"auth\":{\"type\":\"string\",\"description\":\"default "
|
||||
"/var/log/auth.log\"},"
|
||||
"\"access\":{\"type\":\"string\",\"description\":\"default "
|
||||
"/var/log/nginx/access.log\"},"
|
||||
"\"limit\":{\"type\":\"integer\",\"description\":\"entries, default "
|
||||
"200\"}}}",
|
||||
t_log_timeline },
|
||||
};
|
||||
|
||||
const size_t TOOLS_BLUE_N = sizeof(TOOLS_BLUE) / sizeof(TOOLS_BLUE[0]);
|
||||
@@ -826,6 +826,94 @@ static void t_firmware_scan(mcp_conn *c, const mcp_json *args, void *user)
|
||||
mcp_buf_free(&b);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- esp_app_info */
|
||||
|
||||
static void t_esp_app_info(mcp_conn *c, const mcp_json *args, void *user)
|
||||
{
|
||||
const char *path = mcp_arg_string(args, "path");
|
||||
int offset = mcp_arg_int(args, "offset", 0);
|
||||
unsigned char *buf = NULL;
|
||||
size_t len = 0;
|
||||
const unsigned char *d;
|
||||
char version[33];
|
||||
char project[33];
|
||||
char build_time[17];
|
||||
char build_date[17];
|
||||
char idf[33];
|
||||
char sha[65];
|
||||
int desc_ok = 0;
|
||||
int i;
|
||||
mcp_buf b;
|
||||
|
||||
(void)user;
|
||||
if (path == NULL || *path == '\0') {
|
||||
mcp_reply_error(c, "path is required");
|
||||
return;
|
||||
}
|
||||
if (offset < 0 || offset > (16 << 20)) {
|
||||
mcp_reply_error(c, "offset out of range (0..16777216)");
|
||||
return;
|
||||
}
|
||||
buf = esp_read_all(path, 32UL << 20, &len);
|
||||
if (buf == NULL) {
|
||||
mcp_reply_error(c, "cannot read the image (max 32 MiB)");
|
||||
return;
|
||||
}
|
||||
if ((size_t)offset + 8 > len || buf[offset] != 0xe9) {
|
||||
free(buf);
|
||||
mcp_reply_error(c, "no ESP app header at the offset");
|
||||
return;
|
||||
}
|
||||
version[0] = project[0] = build_time[0] = build_date[0] = idf[0] = '\0';
|
||||
sha[0] = '\0';
|
||||
if ((size_t)offset + 0x20 + 176 <= len) {
|
||||
d = buf + offset + 0x20;
|
||||
if (esp_le32(d) == 0xabcd5432u) {
|
||||
desc_ok = 1;
|
||||
snprintf(version, sizeof(version), "%.32s",
|
||||
(const char *)(d + 16));
|
||||
snprintf(project, sizeof(project), "%.32s",
|
||||
(const char *)(d + 48));
|
||||
snprintf(build_time, sizeof(build_time), "%.16s",
|
||||
(const char *)(d + 80));
|
||||
snprintf(build_date, sizeof(build_date), "%.16s",
|
||||
(const char *)(d + 96));
|
||||
snprintf(idf, sizeof(idf), "%.32s", (const char *)(d + 112));
|
||||
for (i = 0; i < 32; i++)
|
||||
snprintf(sha + i * 2, 3, "%02x", d[144 + i]);
|
||||
sha[64] = '\0';
|
||||
}
|
||||
}
|
||||
mcp_buf_init(&b);
|
||||
mcp_buf_puts(&b, "{\"path\":");
|
||||
apex_json_str(&b, path);
|
||||
mcp_buf_printf(&b, ",\"offset\":%d,\"esp_app\":true,\"segments\":%d,"
|
||||
"\"entry\":\"0x%08lx\",\"descriptor\":",
|
||||
offset, buf[offset + 1],
|
||||
(unsigned long)esp_le32(buf + offset + 4));
|
||||
if (desc_ok) {
|
||||
mcp_buf_puts(&b, "{\"version\":");
|
||||
apex_json_str(&b, version);
|
||||
mcp_buf_puts(&b, ",\"project_name\":");
|
||||
apex_json_str(&b, project);
|
||||
mcp_buf_puts(&b, ",\"build_time\":");
|
||||
apex_json_str(&b, build_time);
|
||||
mcp_buf_puts(&b, ",\"build_date\":");
|
||||
apex_json_str(&b, build_date);
|
||||
mcp_buf_puts(&b, ",\"idf_version\":");
|
||||
apex_json_str(&b, idf);
|
||||
mcp_buf_puts(&b, ",\"elf_sha256\":");
|
||||
apex_json_str(&b, sha);
|
||||
mcp_buf_puts(&b, "}");
|
||||
} else {
|
||||
mcp_buf_puts(&b, "null");
|
||||
}
|
||||
mcp_buf_puts(&b, "}");
|
||||
free(buf);
|
||||
mcp_reply_json(c, b.p);
|
||||
mcp_buf_free(&b);
|
||||
}
|
||||
|
||||
const mcp_tool TOOLS_ESP[] = {
|
||||
{ "esp_info",
|
||||
"Identify the attached ESP32 family board: run esptool chip_id on the "
|
||||
@@ -897,6 +985,17 @@ const mcp_tool TOOLS_ESP[] = {
|
||||
"\"path\":{\"type\":\"string\",\"description\":\"firmware dump\"}},"
|
||||
"\"required\":[\"path\"]}",
|
||||
t_firmware_scan },
|
||||
{ "esp_app_info",
|
||||
"Read an ESP app image offline: header magic 0xE9, segment count and "
|
||||
"entry address, then the esp_app_desc_t at 0x20 (magic 0xABCD5432) with "
|
||||
"version, project name, build time/date, IDF version and the ELF "
|
||||
"SHA-256. The offset can point at an OTA partition inside a full dump. "
|
||||
"Read-only.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"path\":{\"type\":\"string\",\"description\":\"image or flash dump\"},"
|
||||
"\"offset\":{\"type\":\"integer\",\"description\":\"default 0\"}},"
|
||||
"\"required\":[\"path\"]}",
|
||||
t_esp_app_info },
|
||||
};
|
||||
|
||||
const size_t TOOLS_ESP_N = sizeof(TOOLS_ESP) / sizeof(TOOLS_ESP[0]);
|
||||
+274
@@ -3354,6 +3354,254 @@ static void t_csrf_audit(mcp_conn *c, const mcp_json *args, void *user)
|
||||
free(resp);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ api_auth_audit */
|
||||
|
||||
static void t_api_auth_audit(mcp_conn *c, const mcp_json *args, void *user)
|
||||
{
|
||||
const char *target = mcp_arg_string(args, "target");
|
||||
const char *endpoints_arg = mcp_arg_string(args, "endpoints");
|
||||
int port = mcp_arg_int(args, "port", 80);
|
||||
int tls = mcp_arg_bool(args, "tls", apex_looks_tls(port));
|
||||
char paths[20][256];
|
||||
int npaths = 0;
|
||||
mcp_buf b;
|
||||
int first = 1;
|
||||
int tested = 0;
|
||||
int open_count = 0;
|
||||
int saved = 0;
|
||||
int i;
|
||||
|
||||
(void)user;
|
||||
if (target == NULL || *target == '\0' || endpoints_arg == NULL ||
|
||||
*endpoints_arg == '\0') {
|
||||
mcp_reply_error(c, "target and endpoints are required");
|
||||
return;
|
||||
}
|
||||
{
|
||||
char *copy = strdup(endpoints_arg);
|
||||
char *save = NULL;
|
||||
char *tok;
|
||||
|
||||
if (copy == NULL) {
|
||||
mcp_reply_error(c, "out of memory");
|
||||
return;
|
||||
}
|
||||
tok = strtok_r(copy, ",", &save);
|
||||
while (tok != NULL && npaths < 20) {
|
||||
while (*tok == ' ' || *tok == '\t')
|
||||
tok++;
|
||||
if (*tok != '\0') {
|
||||
const char *p = *tok == '/' ? "" : "/";
|
||||
|
||||
snprintf(paths[npaths], sizeof(paths[0]), "%s%.200s", p,
|
||||
tok);
|
||||
npaths++;
|
||||
}
|
||||
tok = strtok_r(NULL, ",", &save);
|
||||
}
|
||||
free(copy);
|
||||
}
|
||||
if (npaths == 0) {
|
||||
mcp_reply_error(c, "no endpoint paths given");
|
||||
return;
|
||||
}
|
||||
if (!gated(c, "api_auth_audit", target, port))
|
||||
return;
|
||||
mcp_buf_init(&b);
|
||||
mcp_buf_puts(&b, "{\"target\":");
|
||||
apex_json_str(&b, target);
|
||||
mcp_buf_printf(&b, ",\"port\":%d,\"endpoints\":[", port);
|
||||
for (i = 0; i < npaths; i++) {
|
||||
char status[256];
|
||||
char content_type[160];
|
||||
char *resp = NULL;
|
||||
size_t len = 0;
|
||||
int code;
|
||||
int open;
|
||||
int auth_required;
|
||||
int json;
|
||||
char *evidence = NULL;
|
||||
|
||||
status[0] = '\0';
|
||||
content_type[0] = '\0';
|
||||
if (apex_http_once(target, port, tls, "GET", paths[i], NULL, NULL,
|
||||
8000, &resp, &len, status,
|
||||
sizeof(status)) != 0)
|
||||
continue;
|
||||
tested++;
|
||||
code = apex_status_code(status);
|
||||
response_header(resp, len, "Content-Type", content_type,
|
||||
sizeof(content_type));
|
||||
open = code >= 200 && code < 300;
|
||||
auth_required = code == 401 || code == 403;
|
||||
json = strcasestr(content_type, "json") != NULL;
|
||||
if (open) {
|
||||
open_count++;
|
||||
if (saved < 3) {
|
||||
char label[64];
|
||||
|
||||
snprintf(label, sizeof(label), "api-%.40s", paths[i]);
|
||||
evidence = apex_evidence_save(label, resp, len);
|
||||
saved++;
|
||||
}
|
||||
}
|
||||
if (!first)
|
||||
mcp_buf_puts(&b, ",");
|
||||
first = 0;
|
||||
mcp_buf_puts(&b, "{\"path\":");
|
||||
apex_json_str(&b, paths[i]);
|
||||
mcp_buf_printf(&b, ",\"status\":%d,\"bytes\":%lu,\"open\":%s,"
|
||||
"\"auth_required\":%s,\"json\":%s,\"evidence\":",
|
||||
code, (unsigned long)len, open ? "true" : "false",
|
||||
auth_required ? "true" : "false",
|
||||
json ? "true" : "false");
|
||||
if (evidence != NULL)
|
||||
apex_json_str(&b, evidence);
|
||||
else
|
||||
mcp_buf_puts(&b, "null");
|
||||
mcp_buf_puts(&b, "}");
|
||||
free(evidence);
|
||||
free(resp);
|
||||
}
|
||||
mcp_buf_printf(&b, "],\"tested\":%d,\"open_count\":%d}", tested,
|
||||
open_count);
|
||||
apex_audit("api_auth_audit", target, port, open_count == 0,
|
||||
open_count == 0 ? "endpoints require auth or are absent"
|
||||
: "endpoints answer without auth", "list");
|
||||
mcp_reply_json(c, b.p);
|
||||
mcp_buf_free(&b);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- cache_audit */
|
||||
|
||||
typedef struct {
|
||||
int status;
|
||||
char cache_control[256];
|
||||
char pragma[64];
|
||||
char age[32];
|
||||
char vary[128];
|
||||
char xcache[64];
|
||||
} cache_info;
|
||||
|
||||
static void cache_probe(const char *target, int port, int tls,
|
||||
const char *path, cache_info *ci)
|
||||
{
|
||||
char status[256];
|
||||
char *resp = NULL;
|
||||
size_t len = 0;
|
||||
|
||||
memset(ci, 0, sizeof(*ci));
|
||||
status[0] = '\0';
|
||||
if (apex_http_once(target, port, tls, "GET", path, NULL, NULL, 8000,
|
||||
&resp, &len, status, sizeof(status)) != 0)
|
||||
return;
|
||||
ci->status = apex_status_code(status);
|
||||
response_header(resp, len, "Cache-Control", ci->cache_control,
|
||||
sizeof(ci->cache_control));
|
||||
response_header(resp, len, "Pragma", ci->pragma, sizeof(ci->pragma));
|
||||
response_header(resp, len, "Age", ci->age, sizeof(ci->age));
|
||||
response_header(resp, len, "Vary", ci->vary, sizeof(ci->vary));
|
||||
response_header(resp, len, "X-Cache", ci->xcache, sizeof(ci->xcache));
|
||||
free(resp);
|
||||
}
|
||||
|
||||
static int cache_is_cacheable(const cache_info *ci)
|
||||
{
|
||||
const char *m = strstr(ci->cache_control, "max-age=");
|
||||
|
||||
if (strcasestr(ci->cache_control, "public") != NULL)
|
||||
return 1;
|
||||
if (m != NULL && atoi(m + 8) > 0)
|
||||
return 1;
|
||||
if (strcasestr(ci->cache_control, "no-store") != NULL)
|
||||
return 0;
|
||||
if (atoi(ci->age) > 0)
|
||||
return 1;
|
||||
if (strcasestr(ci->xcache, "hit") != NULL)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void t_cache_audit(mcp_conn *c, const mcp_json *args, void *user)
|
||||
{
|
||||
const char *target = mcp_arg_string(args, "target");
|
||||
const char *path = mcp_arg_string(args, "path");
|
||||
const char *param = mcp_arg_string(args, "param");
|
||||
int port = mcp_arg_int(args, "port", 80);
|
||||
int tls = mcp_arg_bool(args, "tls", apex_looks_tls(port));
|
||||
char req[1200];
|
||||
char marker[64];
|
||||
cache_info clean;
|
||||
cache_info param_req;
|
||||
int cacheable;
|
||||
mcp_buf b;
|
||||
int findings = 0;
|
||||
|
||||
(void)user;
|
||||
if (target == NULL || *target == '\0') {
|
||||
mcp_reply_error(c, "target is required");
|
||||
return;
|
||||
}
|
||||
if (path == NULL || *path == '\0')
|
||||
path = "/";
|
||||
if (path[0] != '/') {
|
||||
mcp_reply_error(c, "path must start with /");
|
||||
return;
|
||||
}
|
||||
if (param == NULL || *param == '\0')
|
||||
param = "q";
|
||||
if (!gated(c, "cache_audit", target, port))
|
||||
return;
|
||||
snprintf(marker, sizeof(marker), "apex%ld", (long)getpid());
|
||||
cache_probe(target, port, tls, path, &clean);
|
||||
snprintf(req, sizeof(req), "%s%s%s=%s", path,
|
||||
strchr(path, '?') != NULL ? "&" : "?", param, marker);
|
||||
cache_probe(target, port, tls, req, ¶m_req);
|
||||
cacheable = cache_is_cacheable(¶m_req);
|
||||
mcp_buf_init(&b);
|
||||
mcp_buf_puts(&b, "{\"target\":");
|
||||
apex_json_str(&b, target);
|
||||
mcp_buf_printf(&b, ",\"port\":%d,\"path\":", port);
|
||||
apex_json_str(&b, path);
|
||||
mcp_buf_puts(&b, ",\"param\":");
|
||||
apex_json_str(&b, param);
|
||||
mcp_buf_puts(&b, ",\"clean\":{\"status\":");
|
||||
mcp_buf_printf(&b, "%d,\"cache_control\":", clean.status);
|
||||
apex_json_str(&b, clean.cache_control);
|
||||
mcp_buf_puts(&b, ",\"age\":");
|
||||
apex_json_str(&b, clean.age);
|
||||
mcp_buf_puts(&b, ",\"vary\":");
|
||||
apex_json_str(&b, clean.vary);
|
||||
mcp_buf_puts(&b, "},\"parameterized\":{\"status\":");
|
||||
mcp_buf_printf(&b, "%d,\"cache_control\":", param_req.status);
|
||||
apex_json_str(&b, param_req.cache_control);
|
||||
mcp_buf_puts(&b, ",\"age\":");
|
||||
apex_json_str(&b, param_req.age);
|
||||
mcp_buf_puts(&b, ",\"vary\":");
|
||||
apex_json_str(&b, param_req.vary);
|
||||
mcp_buf_printf(&b, "},\"cacheable\":%s,\"findings\":[",
|
||||
cacheable ? "true" : "false");
|
||||
if (cacheable) {
|
||||
findings++;
|
||||
mcp_buf_puts(&b, "{\"id\":\"parameterized-cacheable\","
|
||||
"\"severity\":\"medium\",\"detail\":"
|
||||
"\"a response that takes a parameter is cacheable\"}");
|
||||
}
|
||||
if (cacheable && param_req.vary[0] == '\0') {
|
||||
if (findings > 0)
|
||||
mcp_buf_puts(&b, ",");
|
||||
findings++;
|
||||
mcp_buf_puts(&b, "{\"id\":\"missing-vary\",\"severity\":\"low\","
|
||||
"\"detail\":\"cacheable response has no Vary header\"}");
|
||||
}
|
||||
mcp_buf_printf(&b, "],\"findings_count\":%d}", findings);
|
||||
apex_audit("cache_audit", target, port, !cacheable,
|
||||
cacheable ? "parameterized response is cacheable"
|
||||
: "no parameterized caching", path);
|
||||
mcp_reply_json(c, b.p);
|
||||
mcp_buf_free(&b);
|
||||
}
|
||||
|
||||
const mcp_tool TOOLS_RED[] = {
|
||||
{ "vuln_check",
|
||||
"Non-destructive verification of exposed artifacts on one web target: "
|
||||
@@ -3651,6 +3899,32 @@ const mcp_tool TOOLS_RED[] = {
|
||||
"\"tls\":{\"type\":\"boolean\"}},"
|
||||
"\"required\":[\"target\"]}",
|
||||
t_csrf_audit },
|
||||
{ "api_auth_audit",
|
||||
"Request a list of API endpoints without credentials and report each "
|
||||
"status, size, whether it answered 2xx, whether auth is demanded (401/"
|
||||
"403) and whether the answer is JSON; open responses are saved as "
|
||||
"evidence. One GET per endpoint. Gate: the target must be in scope.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"target\":{\"type\":\"string\"},"
|
||||
"\"port\":{\"type\":\"integer\",\"description\":\"default 80\"},"
|
||||
"\"endpoints\":{\"type\":\"string\",\"description\":\"comma list, "
|
||||
"max 20\"},"
|
||||
"\"tls\":{\"type\":\"boolean\"}},"
|
||||
"\"required\":[\"target\",\"endpoints\"]}",
|
||||
t_api_auth_audit },
|
||||
{ "cache_audit",
|
||||
"Fetch a path twice (clean and with a marker parameter) and compare "
|
||||
"Cache-Control, Pragma, Age, Vary, X-Cache: flags a parameterized "
|
||||
"response that is cacheable and a cacheable response without Vary. Two "
|
||||
"GETs, no credentials. Gate: the target must be in scope.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"target\":{\"type\":\"string\"},"
|
||||
"\"port\":{\"type\":\"integer\",\"description\":\"default 80\"},"
|
||||
"\"path\":{\"type\":\"string\",\"description\":\"default /\"},"
|
||||
"\"param\":{\"type\":\"string\",\"description\":\"default q\"},"
|
||||
"\"tls\":{\"type\":\"boolean\"}},"
|
||||
"\"required\":[\"target\"]}",
|
||||
t_cache_audit },
|
||||
};
|
||||
|
||||
const size_t TOOLS_RED_N = sizeof(TOOLS_RED) / sizeof(TOOLS_RED[0]);
|
||||
+1
-1
@@ -21,7 +21,7 @@ import re
|
||||
import sys
|
||||
|
||||
HERE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
EXPECTED_TOOLS = 120
|
||||
EXPECTED_TOOLS = 124
|
||||
GATE = ("gated(", "gated_cmd(", "gated_run(", "apex_scope_check(")
|
||||
NET = ("http_once(", "tcp_connect_host(", "tcp_probe(", "apex_run(")
|
||||
# Tools whose "target" argument filters local records; they never touch it.
|
||||
|
||||
+145
-2
@@ -134,7 +134,7 @@ res, _ = run([
|
||||
], home=empty)
|
||||
check("tools/list answers", any(r.get("id") == 1 for r in res))
|
||||
tools = [r for r in res if r.get("id") == 1][0]["result"]["tools"]
|
||||
check("120 tools registered", len(tools) == 120, len(tools))
|
||||
check("124 tools registered", len(tools) == 124, len(tools))
|
||||
names = {t["name"] for t in tools}
|
||||
for need in ("portscan", "nmap", "http_request", "marauder_scan",
|
||||
"method_playbook", "finding_add", "finding_update", "scope_check",
|
||||
@@ -1560,7 +1560,7 @@ try:
|
||||
check("http initialize", init["result"]["serverInfo"]["name"] == "apex-twin",
|
||||
init)
|
||||
listing = post({"jsonrpc": "2.0", "id": 2, "method": "tools/list"})
|
||||
check("http tools/list", len(listing["result"]["tools"]) == 120)
|
||||
check("http tools/list", len(listing["result"]["tools"]) == 124)
|
||||
shown = post(call(3, "scope_show"))
|
||||
check("http scope_show", '"loaded":true' in shown["result"]["content"][0]["text"])
|
||||
# the id must be the request's id, not one found inside the arguments
|
||||
@@ -5461,6 +5461,149 @@ shutil.rmtree(sshd_root, ignore_errors=True)
|
||||
shutil.rmtree(pam_root, ignore_errors=True)
|
||||
shutil.rmtree(net_home2, ignore_errors=True)
|
||||
|
||||
print("\n== ESP app info, API auth, cache and log timeline ==")
|
||||
|
||||
app_img = bytearray(0x200)
|
||||
app_img[0] = 0xE9
|
||||
app_img[1] = 3
|
||||
struct.pack_into("<I", app_img, 4, 0x40080000)
|
||||
struct.pack_into("<I", app_img, 0x20, 0xABCD5432)
|
||||
app_img[0x20 + 16:0x20 + 21] = b"1.2.3"
|
||||
app_img[0x20 + 48:0x20 + 57] = b"apex-test"
|
||||
app_img[0x20 + 80:0x20 + 88] = b"12:00:00"
|
||||
app_img[0x20 + 96:0x20 + 107] = b"Nov 21 2026"
|
||||
app_img[0x20 + 112:0x20 + 118] = b"v5.1.2"
|
||||
app_img[0x20 + 144:0x20 + 176] = bytes(range(32))
|
||||
app_dir = tempfile.mkdtemp(prefix="apex-app-")
|
||||
app_path = os.path.join(app_dir, "app.bin")
|
||||
with open(app_path, "wb") as f:
|
||||
f.write(app_img)
|
||||
|
||||
|
||||
class _ApiHandler(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
path = urllib.parse.urlsplit(self.path).path
|
||||
if path == "/public":
|
||||
body = b'{"ok":true}'
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
elif path == "/private":
|
||||
body = b"no"
|
||||
self.send_response(401)
|
||||
self.send_header("Content-Type", "text/plain")
|
||||
else:
|
||||
body = b"missing"
|
||||
self.send_response(404)
|
||||
self.send_header("Content-Type", "text/plain")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def log_message(self, *args):
|
||||
pass
|
||||
|
||||
|
||||
class _CacheHandler(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
path = urllib.parse.urlsplit(self.path).path
|
||||
body = b"page"
|
||||
self.send_response(200)
|
||||
if path == "/cached":
|
||||
self.send_header("Cache-Control", "public, max-age=60")
|
||||
self.send_header("Age", "10")
|
||||
else:
|
||||
self.send_header("Cache-Control", "private, no-store")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def log_message(self, *args):
|
||||
pass
|
||||
|
||||
|
||||
api_srv = http.server.HTTPServer(("127.0.0.1", 0), _ApiHandler)
|
||||
api_port = api_srv.server_address[1]
|
||||
threading.Thread(target=api_srv.serve_forever, daemon=True).start()
|
||||
cache_srv = http.server.HTTPServer(("127.0.0.1", 0), _CacheHandler)
|
||||
cache_port = cache_srv.server_address[1]
|
||||
threading.Thread(target=cache_srv.serve_forever, daemon=True).start()
|
||||
|
||||
timeline_home = tempfile.mkdtemp(prefix="apex-tl-")
|
||||
auth_fixture = os.path.join(timeline_home, "auth-fixture.log")
|
||||
access_fixture = os.path.join(timeline_home, "access-fixture.log")
|
||||
with open(auth_fixture, "w") as f:
|
||||
f.write("Jan 1 10:00:05 host sshd[1]: Accepted password for alice\n")
|
||||
f.write("Jan 1 10:00:10 host sshd[2]: Failed password for root\n")
|
||||
with open(access_fixture, "w") as f:
|
||||
f.write('10.0.0.7 - - [01/Jan/2026:10:00:07 +0000] '
|
||||
'"GET / HTTP/1.1" 200 12 "-" "curl"\n')
|
||||
write_scope(timeline_home, {"label": "tl", "expires": "2099-12-31T23:59:59Z",
|
||||
"allow_private": True, "allow_ip": ["127.0.0.1"],
|
||||
"allow_port": [str(api_port), str(cache_port)]})
|
||||
res, _ = run([
|
||||
call(1, "esp_app_info", path=app_path),
|
||||
call(2, "api_auth_audit", target="127.0.0.1", port=api_port,
|
||||
endpoints="/public,/private,/missing", tls=False),
|
||||
call(3, "cache_audit", target="127.0.0.1", port=cache_port,
|
||||
path="/cached", tls=False),
|
||||
call(4, "cache_audit", target="127.0.0.1", port=cache_port,
|
||||
path="/private", tls=False),
|
||||
call(5, "log_timeline", auth=auth_fixture, access=access_fixture),
|
||||
call(6, "api_auth_audit", target="198.51.100.9", port=80,
|
||||
endpoints="/public"),
|
||||
call(7, "esp_app_info", path="/nonexistent-app.bin"),
|
||||
], home=timeline_home)
|
||||
by_id = {r.get("id"): r for r in res}
|
||||
app = json.loads(text(by_id[1]))
|
||||
check("esp_app_info reads the image header",
|
||||
app["esp_app"] is True and app["segments"] == 3 and
|
||||
app["entry"] == "0x40080000", app)
|
||||
desc = app["descriptor"]
|
||||
check("esp_app_info reads the app descriptor",
|
||||
desc is not None and desc["version"] == "1.2.3" and
|
||||
desc["project_name"] == "apex-test" and
|
||||
desc["idf_version"] == "v5.1.2", desc)
|
||||
check("esp_app_info reports the build date and ELF hash",
|
||||
desc["build_date"] == "Nov 21 2026" and
|
||||
desc["elf_sha256"].startswith("000102030405"), desc)
|
||||
api = json.loads(text(by_id[2]))
|
||||
paths = {e["path"]: e for e in api["endpoints"]}
|
||||
check("api_auth_audit probes all endpoints",
|
||||
api["tested"] == 3 and api["open_count"] == 1, api)
|
||||
check("api_auth_audit marks the open and protected endpoints",
|
||||
paths["/public"]["open"] is True and paths["/public"]["json"] is True and
|
||||
paths["/private"]["auth_required"] is True and
|
||||
paths["/missing"]["status"] == 404, paths)
|
||||
check("api_auth_audit keeps an open response as evidence",
|
||||
paths["/public"]["evidence"] and
|
||||
os.path.isfile(paths["/public"]["evidence"]), paths["/public"])
|
||||
cached = json.loads(text(by_id[3]))
|
||||
check("cache_audit flags a cacheable parameterized response",
|
||||
cached["cacheable"] is True and
|
||||
{f["id"] for f in cached["findings"]} ==
|
||||
{"parameterized-cacheable", "missing-vary"}, cached)
|
||||
private = json.loads(text(by_id[4]))
|
||||
check("cache_audit leaves a no-store response alone",
|
||||
private["cacheable"] is False and private["findings_count"] == 0,
|
||||
private)
|
||||
timeline = json.loads(text(by_id[5]))
|
||||
check("log_timeline merges and sorts both sources",
|
||||
timeline["count"] == 3 and
|
||||
[e["source"] for e in timeline["entries"]] ==
|
||||
["auth", "access", "auth"], timeline)
|
||||
check("log_timeline orders by timestamp",
|
||||
[e["time"] for e in timeline["entries"]] ==
|
||||
["20260101100005", "20260101100007", "20260101100010"], timeline)
|
||||
check("api_auth_audit refuses an out-of-scope target", err(by_id[6]),
|
||||
text(by_id[6]))
|
||||
check("esp_app_info rejects a missing file", err(by_id[7]), text(by_id[7]))
|
||||
api_srv.shutdown()
|
||||
api_srv.server_close()
|
||||
cache_srv.shutdown()
|
||||
cache_srv.server_close()
|
||||
shutil.rmtree(app_dir, ignore_errors=True)
|
||||
shutil.rmtree(timeline_home, ignore_errors=True)
|
||||
|
||||
print("\n== esp32 tools ==")
|
||||
esp_home = tempfile.mkdtemp(prefix="apex-esp-")
|
||||
write_scope(esp_home, {"label": "esp", "expires": "2099-12-31T23:59:59Z"})
|
||||
|
||||
Reference in new issue
Block a user