apex-twin 1.71.0: limits, access.conf and pwquality audits, Kafka Connect probe
Three blue config audits: limits_audit (nofile/nproc/memlock unlimited, core dumps above zero, world-writable files; only a literal "unlimited" counts), access_conf_audit (+ rule for ALL, a + rule without tty/host restriction and a trailing "+ : ALL : ALL" default-allow) and pwquality_audit (minlen below 8, minclass 0, dictcheck=0, enforcing=0, commented defaults stay silent). One red probe: kafka_connect_probe queries /, /connectors and /connector-plugins on 8083; a 2xx connector list is an unauthenticated Kafka Connect worker and is saved as evidence. Corrected the tranche plan: login_defs_audit and nsswitch_audit already existed, so the scope moved to the three genuinely missing files. Tests: 1314 end-to-end checks green, 240 fuzz cases, analyze clean, coverage 84.8%, distcheck from the tarball passes (313 s).
This commit is contained in:
1 parent
357c6575e9
commit
e8d2e4ccd6
9 files changed
+827
-13
No files matched your search
@@ -8,6 +8,25 @@ 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.71.0 — 2026-11-23 — this change
|
||||
|
||||
- **limits.conf** (`limits_audit`): `nofile`, `nproc` or `memlock` set to
|
||||
`unlimited`, a `core` limit above zero (core dumps), and world-writable
|
||||
`limits.conf` or `limits.d` files. Only a literal `unlimited` is flagged; a
|
||||
large number is still a ceiling. Lines are domain, type, item, value.
|
||||
- **access.conf** (`access_conf_audit`): a `+` rule for `ALL`, a `+` rule with
|
||||
no tty or host restriction, and a last rule of `+ : ALL : ALL`, which turns
|
||||
the file into a default-allow. The file stops at the first match, so the
|
||||
position of a rule is what matters.
|
||||
- **pwquality.conf** (`pwquality_audit`): `minlen` below 8, `minclass 0`,
|
||||
`dictcheck=0`, `enforcing=0`, and world-writable files. Commented defaults
|
||||
stay silent.
|
||||
- **Kafka Connect** (`kafka_connect_probe`): `/`, `/connectors` and
|
||||
`/connector-plugins` on 8083 without credentials; the connector list
|
||||
exposes every connector and its configuration and is saved as evidence.
|
||||
- Tests with limits, access.conf and pwquality trees plus an open and a 401
|
||||
Kafka Connect worker. 1314 checks.
|
||||
|
||||
## 1.70.0 — 2026-11-23 — this change
|
||||
|
||||
- **fstab** (`fstab_audit`): a `/tmp`, `/var/tmp` or `/dev/shm` mount without
|
||||
|
||||
@@ -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.
|
||||
|
||||
**318 tools · 1302 end-to-end checks · 240 fuzz cases · 84.7% line coverage · ~1041 KiB**
|
||||
**322 tools · 1314 end-to-end checks · 240 fuzz cases · 84.8% line coverage · ~1041 KiB**
|
||||
|
||||
```
|
||||
$ ./apex-twin --check
|
||||
{"version":"1.70.0","tools":318,...,"scope":{"loaded":true,...}}
|
||||
{"version":"1.71.0","tools":322,...,"scope":{"loaded":true,...}}
|
||||
```
|
||||
|
||||
APEX TWIN was inspired by [ARTEX](https://github.com/Autumn-27/artex) (scope
|
||||
@@ -229,6 +229,7 @@ uploads and secret-file reads. It does not execute anything.
|
||||
| `harbor_probe` | `/api/v2.0/projects` without auth; project list as evidence |
|
||||
| `portainer_probe` | `/api/status` and `/api/users/admin/check`; setup-open or unauth admin check |
|
||||
| `argocd_probe` | `/api/v1/applications` without a token; deployed apps as evidence |
|
||||
| `kafka_connect_probe` | `/connectors` on 8083 without auth; connector list as evidence |
|
||||
| `cookie_audit` | Secure/HttpOnly/SameSite per cookie, incl. `SameSite=None` without Secure |
|
||||
| `http_options` | `Allow`/`Public`; flags TRACE, PUT, DELETE |
|
||||
| `sqli_probe` | Quote and boolean payloads; differing answers are a **lead**, not proof |
|
||||
@@ -515,6 +516,9 @@ command in the allowlist: a receiver is a scanner, a transmitter is an attack.
|
||||
| `fstab_audit` | fstab: /tmp and friends without nosuid/nodev/noexec, user mounts |
|
||||
| `modprobe_audit` | modprobe.d: `install` hooks that run a command as root |
|
||||
| `grub_audit` | /etc/default/grub: mitigations=off, nokaslr, no init_on_alloc |
|
||||
| `limits_audit` | limits.conf: unlimited nofile/nproc/memlock, core dumps |
|
||||
| `access_conf_audit` | access.conf: `+ : ALL : ALL`, default-allow tail |
|
||||
| `pwquality_audit` | pwquality.conf: minlen < 8, minclass 0, enforcing=0 |
|
||||
|
||||
### ESP32
|
||||
|
||||
@@ -983,7 +987,7 @@ src/tools_red.c vuln_check, subdomain_enum, cred_test, vhost_discovery,
|
||||
logstash_api_probe, amqp_probe, tls_chain_probe,
|
||||
smtp_auth_probe, jenkins_api_probe, nexus_probe,
|
||||
gitea_api_probe, harbor_probe, portainer_probe,
|
||||
argocd_probe
|
||||
argocd_probe, kafka_connect_probe
|
||||
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,
|
||||
@@ -991,7 +995,8 @@ src/tools_blue.c hardening_audit, log_audit, ioc_scan, web_log_audit,
|
||||
package_integrity, mount_audit, firewall_audit,
|
||||
systemd_audit (and ~160 more service config audits,
|
||||
newest: podman_audit, buildkitd_audit, supervisor_audit,
|
||||
fstab_audit, modprobe_audit, grub_audit)
|
||||
fstab_audit, modprobe_audit, grub_audit,
|
||||
limits_audit, access_conf_audit, pwquality_audit)
|
||||
src/tools_esp.c esp_info, esp_monitor, esp_read_flash, esp_flash,
|
||||
esp_partition_table, esp_nvs_parse, firmware_scan,
|
||||
esp_app_info, esp_image_verify
|
||||
@@ -1028,7 +1033,7 @@ examples/ scope.json
|
||||
|
||||
## Status
|
||||
|
||||
1.70.0. Built and run: 318 tools, 1302 checks, 240 fuzz cases and 84.7% line
|
||||
1.71.0. Built and run: 322 tools, 1314 checks, 240 fuzz cases and 84.8% 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
|
||||
|
||||
+1
-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.70.x** (`src/apex.h`, `APEX_VERSION`). Security fixes land on the current
|
||||
is **1.71.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.
|
||||
|
||||
+4
-3
@@ -1,5 +1,5 @@
|
||||
.\" apex-twin.1 - manual page for APEX TWIN
|
||||
.TH APEX-TWIN 1 "2026-11-21" "apex-twin 1.70.0" "User Commands"
|
||||
.TH APEX-TWIN 1 "2026-11-21" "apex-twin 1.71.0" "User Commands"
|
||||
.SH NAME
|
||||
apex-twin \- scope\-gated offensive\-security MCP server
|
||||
.SH SYNOPSIS
|
||||
@@ -46,7 +46,7 @@ sip_probe, telnet_probe, http_methods, websocket_probe, ike_probe, snmp_walk,
|
||||
ldap_search, openapi_discovery, csrf_audit, rpc_probe, ntp_probe, dnssec_check, smtp_starttls_probe, tls_ocsp_probe, alpn_probe, webdav_probe, dns_wildcard_check, dns_caa_check, sni_vhost_check, tls_client_auth_probe, kubernetes_api_probe,
|
||||
dns_ns_consistency, dns_dangling_cname, http_redirect_audit,
|
||||
websocket_origin_check, dns_fcrdns_check, dns_soa_mname_check, http_redirect_audit,
|
||||
websocket_origin_check, hsts_audit, tls_hostname_check, ftp_tls_probe, zookeeper_4lw_probe, etcd_api_probe, docker_registry_probe, consul_api_probe, couchdb_probe, prometheus_api_probe, rabbitmq_management_probe, grafana_api_probe, minio_admin_probe, nats_monitoring_probe, influxdb_probe, clickhouse_probe, kibana_api_probe, logstash_api_probe, amqp_probe, tls_chain_probe, smtp_auth_probe, jenkins_api_probe, nexus_probe, gitea_api_probe, harbor_probe, portainer_probe, argocd_probe),
|
||||
websocket_origin_check, hsts_audit, tls_hostname_check, ftp_tls_probe, zookeeper_4lw_probe, etcd_api_probe, docker_registry_probe, consul_api_probe, couchdb_probe, prometheus_api_probe, rabbitmq_management_probe, grafana_api_probe, minio_admin_probe, nats_monitoring_probe, influxdb_probe, clickhouse_probe, kibana_api_probe, logstash_api_probe, amqp_probe, tls_chain_probe, smtp_auth_probe, jenkins_api_probe, nexus_probe, gitea_api_probe, harbor_probe, portainer_probe, argocd_probe, kafka_connect_probe),
|
||||
defensive
|
||||
audits (hardening_audit, log_audit, ioc_scan, web_log_audit, detect_rules,
|
||||
integrity_baseline, mitre_map, process_snapshot, persistence_audit,
|
||||
@@ -84,7 +84,8 @@ wpa_supplicant_audit, bluetooth_audit, networkmanager_audit, dbus_audit, passwd_
|
||||
authorized_keys_audit, ld_preload_audit, gitconfig_audit, npmrc_audit,
|
||||
pip_conf_audit, podman_audit, buildkitd_audit,
|
||||
supervisor_audit,
|
||||
fstab_audit, modprobe_audit, grub_audit)
|
||||
fstab_audit, modprobe_audit, grub_audit,
|
||||
limits_audit, access_conf_audit, pwquality_audit)
|
||||
and ESP32 board tools (esp_info, esp_monitor,
|
||||
esp_read_flash, esp_flash, esp_partition_table, esp_nvs_parse, firmware_scan,
|
||||
esp_app_info, esp_image_verify).
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "mcp.h"
|
||||
|
||||
#define APEX_VERSION "1.70.0"
|
||||
#define APEX_VERSION "1.71.0"
|
||||
#define APEX_MAX_OUT (1u << 20)
|
||||
#define APEX_PATH_MAX 512
|
||||
#define APEX_PATH_FULL 1024
|
||||
|
||||
@@ -21619,6 +21619,487 @@ static void t_grub_audit(mcp_conn *c, const mcp_json *args, void *user)
|
||||
mcp_buf_free(&findings);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------- limits_audit */
|
||||
|
||||
/* limits.conf lines are "domain type item value", optionally followed by a
|
||||
* comment. Only a value that is literally "unlimited" removes a ceiling; a
|
||||
* large number is still a ceiling and is not flagged. */
|
||||
static void limits_scan_file(mcp_buf *findings, int *first, int *count,
|
||||
const char *path, int *lines_seen)
|
||||
{
|
||||
static char text[65536];
|
||||
struct stat st;
|
||||
const char *p;
|
||||
|
||||
if (read_text(path, text, sizeof(text)) <= 0)
|
||||
return;
|
||||
if (stat(path, &st) == 0 && (st.st_mode & 0002) != 0) {
|
||||
add_finding(findings, first, "world-writable", "high",
|
||||
"%s is writable by anyone", path);
|
||||
(*count)++;
|
||||
}
|
||||
p = text;
|
||||
while (p != NULL && *p != '\0') {
|
||||
const char *eol = strchr(p, '\n');
|
||||
size_t len = eol != NULL ? (size_t)(eol - p) : strlen(p);
|
||||
char line[1024];
|
||||
char *fields[4];
|
||||
int n = 0;
|
||||
char *s;
|
||||
char *hash;
|
||||
|
||||
if (len >= sizeof(line))
|
||||
len = sizeof(line) - 1;
|
||||
memcpy(line, p, len);
|
||||
line[len] = '\0';
|
||||
trim_eol(line);
|
||||
hash = strchr(line, '#');
|
||||
if (hash != NULL)
|
||||
*hash = '\0';
|
||||
s = line;
|
||||
while (n < 4) {
|
||||
char *tok = s;
|
||||
|
||||
while (*tok == ' ' || *tok == '\t')
|
||||
tok++;
|
||||
if (*tok == '\0')
|
||||
break;
|
||||
fields[n++] = tok;
|
||||
s = tok;
|
||||
while (*s != '\0' && *s != ' ' && *s != '\t')
|
||||
s++;
|
||||
if (*s == '\0')
|
||||
break;
|
||||
*s++ = '\0';
|
||||
}
|
||||
if (n == 4) {
|
||||
const char *item = fields[2];
|
||||
const char *value = fields[3];
|
||||
int unlimited = strcmp(value, "unlimited") == 0;
|
||||
|
||||
(*lines_seen)++;
|
||||
if (unlimited && (strcmp(item, "nofile") == 0 ||
|
||||
strcmp(item, "nproc") == 0 ||
|
||||
strcmp(item, "memlock") == 0)) {
|
||||
add_finding(findings, first, "unlimited-limit",
|
||||
"medium",
|
||||
"%s: %s gets %s %s, a resource without "
|
||||
"a ceiling", path, fields[0], item, value);
|
||||
(*count)++;
|
||||
} else if (strcmp(item, "core") == 0 && !unlimited &&
|
||||
strcmp(value, "0") != 0) {
|
||||
add_finding(findings, first, "core-dumps", "low",
|
||||
"%s: %s keeps core dumps (%s %s)", path,
|
||||
fields[0], item, value);
|
||||
(*count)++;
|
||||
}
|
||||
}
|
||||
p = eol != NULL ? eol + 1 : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void t_limits_audit(mcp_conn *c, const mcp_json *args, void *user)
|
||||
{
|
||||
const char *root = mcp_arg_string(args, "root");
|
||||
char path[1024];
|
||||
DIR *d;
|
||||
struct dirent *ent;
|
||||
mcp_buf b;
|
||||
mcp_buf findings;
|
||||
int first = 1;
|
||||
int count = 0;
|
||||
int files = 0;
|
||||
int lines_seen = 0;
|
||||
|
||||
(void)user;
|
||||
if (root == NULL)
|
||||
root = "";
|
||||
if (strlen(root) > 400) {
|
||||
mcp_reply_error(c, "root path too long");
|
||||
return;
|
||||
}
|
||||
mcp_buf_init(&findings);
|
||||
snprintf(path, sizeof(path), "%.400s/etc/security/limits.conf", root);
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat(path, &st) == 0) {
|
||||
files++;
|
||||
limits_scan_file(&findings, &first, &count, path,
|
||||
&lines_seen);
|
||||
}
|
||||
}
|
||||
snprintf(path, sizeof(path), "%.400s/etc/security/limits.d", root);
|
||||
d = opendir(path);
|
||||
if (d != NULL) {
|
||||
while ((ent = readdir(d)) != NULL) {
|
||||
char file[1200];
|
||||
|
||||
if (ent->d_name[0] == '.')
|
||||
continue;
|
||||
if (strstr(ent->d_name, ".conf") == NULL)
|
||||
continue;
|
||||
snprintf(file, sizeof(file), "%.800s/%.200s", path,
|
||||
ent->d_name);
|
||||
files++;
|
||||
limits_scan_file(&findings, &first, &count, file,
|
||||
&lines_seen);
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
if (files == 0) {
|
||||
mcp_buf_free(&findings);
|
||||
mcp_reply_error(c, "cannot read a limits configuration");
|
||||
return;
|
||||
}
|
||||
mcp_buf_init(&b);
|
||||
mcp_buf_puts(&b, "{\"root\":");
|
||||
apex_json_str(&b, root);
|
||||
mcp_buf_printf(&b, ",\"files\":%d,\"lines\":%d,\"findings_count\":%d,"
|
||||
"\"findings\":[", files, lines_seen, count);
|
||||
if (findings.p != NULL)
|
||||
mcp_buf_add(&b, findings.p, findings.len);
|
||||
mcp_buf_puts(&b, "]}");
|
||||
mcp_reply_json(c, b.p);
|
||||
mcp_buf_free(&b);
|
||||
mcp_buf_free(&findings);
|
||||
}
|
||||
|
||||
static void t_access_conf_audit(mcp_conn *c, const mcp_json *args, void *user)
|
||||
{
|
||||
const char *root = mcp_arg_string(args, "root");
|
||||
char path[1024];
|
||||
static char text[65536];
|
||||
struct stat st;
|
||||
mcp_buf b;
|
||||
mcp_buf findings;
|
||||
int first = 1;
|
||||
int count = 0;
|
||||
int rules = 0;
|
||||
int allow_all = 0;
|
||||
int open_rule = 0;
|
||||
int default_allow = 0;
|
||||
char last_rule[512];
|
||||
const char *p;
|
||||
|
||||
(void)user;
|
||||
if (root == NULL)
|
||||
root = "";
|
||||
if (strlen(root) > 400) {
|
||||
mcp_reply_error(c, "root path too long");
|
||||
return;
|
||||
}
|
||||
snprintf(path, sizeof(path), "%.400s/etc/security/access.conf", root);
|
||||
if (read_text(path, text, sizeof(text)) <= 0) {
|
||||
mcp_reply_error(c, "cannot read /etc/security/access.conf");
|
||||
return;
|
||||
}
|
||||
last_rule[0] = '\0';
|
||||
mcp_buf_init(&findings);
|
||||
if (stat(path, &st) == 0 && (st.st_mode & 0002) != 0) {
|
||||
add_finding(&findings, &first, "world-writable", "high",
|
||||
"%s is writable by anyone", path);
|
||||
count++;
|
||||
}
|
||||
p = text;
|
||||
while (p != NULL && *p != '\0') {
|
||||
const char *eol = strchr(p, '\n');
|
||||
size_t len = eol != NULL ? (size_t)(eol - p) : strlen(p);
|
||||
char line[1024];
|
||||
char *s;
|
||||
char *hash;
|
||||
char *colon;
|
||||
char *perm;
|
||||
char *users;
|
||||
char *rest;
|
||||
|
||||
if (len >= sizeof(line))
|
||||
len = sizeof(line) - 1;
|
||||
memcpy(line, p, len);
|
||||
line[len] = '\0';
|
||||
trim_eol(line);
|
||||
s = line;
|
||||
while (*s == ' ' || *s == '\t')
|
||||
s++;
|
||||
if (*s == '\0' || *s == '#') {
|
||||
p = eol != NULL ? eol + 1 : NULL;
|
||||
continue;
|
||||
}
|
||||
hash = strchr(s, '#');
|
||||
if (hash != NULL)
|
||||
*hash = '\0';
|
||||
{
|
||||
size_t ll = strlen(s);
|
||||
|
||||
while (ll > 0 && (s[ll - 1] == ' ' || s[ll - 1] == '\t'))
|
||||
s[--ll] = '\0';
|
||||
}
|
||||
rules++;
|
||||
snprintf(last_rule, sizeof(last_rule), "%.400s", s);
|
||||
colon = strchr(s, ':');
|
||||
if (colon == NULL) {
|
||||
p = eol != NULL ? eol + 1 : NULL;
|
||||
continue;
|
||||
}
|
||||
*colon = '\0';
|
||||
perm = s;
|
||||
{
|
||||
size_t pl = strlen(perm);
|
||||
|
||||
while (pl > 0 && (perm[pl - 1] == ' ' ||
|
||||
perm[pl - 1] == '\t'))
|
||||
perm[--pl] = '\0';
|
||||
}
|
||||
users = colon + 1;
|
||||
while (*users == ' ' || *users == '\t')
|
||||
users++;
|
||||
rest = strchr(users, ':');
|
||||
if (rest != NULL) {
|
||||
*rest = '\0';
|
||||
rest++;
|
||||
while (*rest == ' ' || *rest == '\t')
|
||||
rest++;
|
||||
}
|
||||
{
|
||||
size_t ul = strlen(users);
|
||||
|
||||
while (ul > 0 && (users[ul - 1] == ' ' ||
|
||||
users[ul - 1] == '\t'))
|
||||
users[--ul] = '\0';
|
||||
}
|
||||
if (strcmp(perm, "+") == 0 && strcmp(users, "ALL") == 0) {
|
||||
allow_all = 1;
|
||||
add_finding(&findings, &first, "allow-all", "high",
|
||||
"a '+' rule admits ALL users: %.200s", s);
|
||||
count++;
|
||||
} else if (strcmp(perm, "+") == 0 &&
|
||||
(rest == NULL || *rest == '\0' ||
|
||||
strcmp(rest, "ALL") == 0)) {
|
||||
open_rule = 1;
|
||||
add_finding(&findings, &first, "unrestricted-allow",
|
||||
"medium",
|
||||
"a '+' rule has no tty or host restriction: "
|
||||
"%.200s", s);
|
||||
count++;
|
||||
}
|
||||
p = eol != NULL ? eol + 1 : NULL;
|
||||
}
|
||||
/* The file is evaluated top to bottom and stops at the first match, so a
|
||||
* trailing allow for ALL is a default-allow even when deny rules exist
|
||||
* above it. */
|
||||
if (last_rule[0] != '\0' && strstr(last_rule, "+") == last_rule &&
|
||||
strstr(last_rule, "ALL") != NULL) {
|
||||
default_allow = 1;
|
||||
add_finding(&findings, &first, "default-allow", "high",
|
||||
"the last rule admits a wide set: %.200s", last_rule);
|
||||
count++;
|
||||
}
|
||||
mcp_buf_init(&b);
|
||||
mcp_buf_puts(&b, "{\"root\":");
|
||||
apex_json_str(&b, root);
|
||||
mcp_buf_printf(&b, ",\"rules\":%d,\"allow_all\":%s,"
|
||||
"\"open_rule\":%s,\"default_allow\":%s,"
|
||||
"\"findings_count\":%d,\"findings\":[",
|
||||
rules, allow_all ? "true" : "false",
|
||||
open_rule ? "true" : "false",
|
||||
default_allow ? "true" : "false", count);
|
||||
if (findings.p != NULL)
|
||||
mcp_buf_add(&b, findings.p, findings.len);
|
||||
mcp_buf_puts(&b, "]}");
|
||||
mcp_reply_json(c, b.p);
|
||||
mcp_buf_free(&b);
|
||||
mcp_buf_free(&findings);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- pwquality_audit */
|
||||
|
||||
/* pwquality.conf is a flat "key = value" file; pwquality.conf.d drops one file
|
||||
* per key. Only definitions count, so a commented default stays silent. */
|
||||
static void pwq_scan_file(mcp_buf *findings, int *first, int *count,
|
||||
const char *path, int *keys, int *weak_minlen,
|
||||
int *no_class, int *no_dict, int *not_enforcing)
|
||||
{
|
||||
static char text[65536];
|
||||
struct stat st;
|
||||
const char *p;
|
||||
|
||||
if (read_text(path, text, sizeof(text)) <= 0)
|
||||
return;
|
||||
if (stat(path, &st) == 0 && (st.st_mode & 0002) != 0) {
|
||||
add_finding(findings, first, "world-writable", "high",
|
||||
"%s is writable by anyone", path);
|
||||
(*count)++;
|
||||
}
|
||||
p = text;
|
||||
while (p != NULL && *p != '\0') {
|
||||
const char *eol = strchr(p, '\n');
|
||||
size_t len = eol != NULL ? (size_t)(eol - p) : strlen(p);
|
||||
char line[1024];
|
||||
char *eq;
|
||||
char *key;
|
||||
char *value;
|
||||
char *end;
|
||||
|
||||
if (len >= sizeof(line))
|
||||
len = sizeof(line) - 1;
|
||||
memcpy(line, p, len);
|
||||
line[len] = '\0';
|
||||
trim_eol(line);
|
||||
key = line;
|
||||
while (*key == ' ' || *key == '\t')
|
||||
key++;
|
||||
if (*key == '#' || *key == '\0') {
|
||||
p = eol != NULL ? eol + 1 : NULL;
|
||||
continue;
|
||||
}
|
||||
eq = strchr(key, '=');
|
||||
if (eq == NULL) {
|
||||
p = eol != NULL ? eol + 1 : NULL;
|
||||
continue;
|
||||
}
|
||||
*eq = '\0';
|
||||
value = eq + 1;
|
||||
while (*value == ' ' || *value == '\t')
|
||||
value++;
|
||||
{
|
||||
size_t vl = strlen(value);
|
||||
|
||||
while (vl > 0 && (value[vl - 1] == ' ' ||
|
||||
value[vl - 1] == '\t' ||
|
||||
value[vl - 1] == '\r'))
|
||||
value[--vl] = '\0';
|
||||
}
|
||||
{
|
||||
size_t kl = strlen(key);
|
||||
|
||||
while (kl > 0 && (key[kl - 1] == ' ' || key[kl - 1] == '\t'))
|
||||
key[--kl] = '\0';
|
||||
}
|
||||
(*keys)++;
|
||||
if (strcmp(key, "minlen") == 0) {
|
||||
long n = strtol(value, &end, 10);
|
||||
|
||||
if (end != value && n < 8) {
|
||||
*weak_minlen = 1;
|
||||
add_finding(findings, first, "weak-minlen", "medium",
|
||||
"%s: minlen is %ld, below 8", path, n);
|
||||
(*count)++;
|
||||
}
|
||||
} else if (strcmp(key, "minclass") == 0) {
|
||||
long n = strtol(value, &end, 10);
|
||||
|
||||
if (end != value && n == 0) {
|
||||
*no_class = 1;
|
||||
add_finding(findings, first, "no-minclass", "medium",
|
||||
"%s: minclass 0, no character classes are "
|
||||
"required", path);
|
||||
(*count)++;
|
||||
}
|
||||
} else if (strcmp(key, "dictcheck") == 0) {
|
||||
long n = strtol(value, &end, 10);
|
||||
|
||||
if (end != value && n == 0) {
|
||||
*no_dict = 1;
|
||||
add_finding(findings, first, "no-dictcheck", "low",
|
||||
"%s: dictcheck=0, dictionary words pass",
|
||||
path);
|
||||
(*count)++;
|
||||
}
|
||||
} else if (strcmp(key, "enforcing") == 0) {
|
||||
long n = strtol(value, &end, 10);
|
||||
|
||||
if (end != value && n == 0) {
|
||||
*not_enforcing = 1;
|
||||
add_finding(findings, first, "not-enforcing", "high",
|
||||
"%s: enforcing=0, weak passwords only warn",
|
||||
path);
|
||||
(*count)++;
|
||||
}
|
||||
}
|
||||
p = eol != NULL ? eol + 1 : NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void t_pwquality_audit(mcp_conn *c, const mcp_json *args, void *user)
|
||||
{
|
||||
const char *root = mcp_arg_string(args, "root");
|
||||
char path[1024];
|
||||
DIR *d;
|
||||
struct dirent *ent;
|
||||
mcp_buf b;
|
||||
mcp_buf findings;
|
||||
int first = 1;
|
||||
int count = 0;
|
||||
int files = 0;
|
||||
int keys = 0;
|
||||
int weak_minlen = 0;
|
||||
int no_class = 0;
|
||||
int no_dict = 0;
|
||||
int not_enforcing = 0;
|
||||
|
||||
(void)user;
|
||||
if (root == NULL)
|
||||
root = "";
|
||||
if (strlen(root) > 400) {
|
||||
mcp_reply_error(c, "root path too long");
|
||||
return;
|
||||
}
|
||||
mcp_buf_init(&findings);
|
||||
snprintf(path, sizeof(path), "%.400s/etc/security/pwquality.conf", root);
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat(path, &st) == 0) {
|
||||
files++;
|
||||
pwq_scan_file(&findings, &first, &count, path, &keys,
|
||||
&weak_minlen, &no_class, &no_dict,
|
||||
¬_enforcing);
|
||||
}
|
||||
}
|
||||
snprintf(path, sizeof(path), "%.400s/etc/security/pwquality.conf.d",
|
||||
root);
|
||||
d = opendir(path);
|
||||
if (d != NULL) {
|
||||
while ((ent = readdir(d)) != NULL) {
|
||||
char file[1200];
|
||||
|
||||
if (ent->d_name[0] == '.')
|
||||
continue;
|
||||
if (strstr(ent->d_name, ".conf") == NULL)
|
||||
continue;
|
||||
snprintf(file, sizeof(file), "%.800s/%.200s", path,
|
||||
ent->d_name);
|
||||
files++;
|
||||
pwq_scan_file(&findings, &first, &count, file, &keys,
|
||||
&weak_minlen, &no_class, &no_dict,
|
||||
¬_enforcing);
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
if (files == 0) {
|
||||
mcp_buf_free(&findings);
|
||||
mcp_reply_error(c, "cannot read a pwquality configuration");
|
||||
return;
|
||||
}
|
||||
mcp_buf_init(&b);
|
||||
mcp_buf_puts(&b, "{\"root\":");
|
||||
apex_json_str(&b, root);
|
||||
mcp_buf_printf(&b, ",\"files\":%d,\"keys\":%d,\"weak_minlen\":%s,"
|
||||
"\"minclass_zero\":%s,\"dictcheck_off\":%s,"
|
||||
"\"not_enforcing\":%s,\"findings_count\":%d,"
|
||||
"\"findings\":[",
|
||||
files, keys, weak_minlen ? "true" : "false",
|
||||
no_class ? "true" : "false",
|
||||
no_dict ? "true" : "false",
|
||||
not_enforcing ? "true" : "false", count);
|
||||
if (findings.p != NULL)
|
||||
mcp_buf_add(&b, findings.p, findings.len);
|
||||
mcp_buf_puts(&b, "]}");
|
||||
mcp_reply_json(c, b.p);
|
||||
mcp_buf_free(&b);
|
||||
mcp_buf_free(&findings);
|
||||
}
|
||||
|
||||
const mcp_tool TOOLS_BLUE[] = {
|
||||
{ "hardening_audit",
|
||||
"Read-only posture audit of the local host: sshd_config (root login, "
|
||||
@@ -22861,6 +23342,29 @@ const mcp_tool TOOLS_BLUE[] = {
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
|
||||
t_grub_audit },
|
||||
{ "limits_audit",
|
||||
"Parse /etc/security/limits.conf and limits.d/*.conf (root prefix): a "
|
||||
"nofile, nproc or memlock limit set to unlimited, a core limit above "
|
||||
"zero, and world-writable files. Each line is domain, type, item, "
|
||||
"value; the domain is reported with the finding. Read-only.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
|
||||
t_limits_audit },
|
||||
{ "access_conf_audit",
|
||||
"Parse /etc/security/access.conf (root prefix): a '+' rule for ALL, a "
|
||||
"'+' rule with no tty or host restriction, and a last rule that ends "
|
||||
"in '+ : ALL : ALL', which makes the file a default-allow. "
|
||||
"World-writable file included. Read-only.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
|
||||
t_access_conf_audit },
|
||||
{ "pwquality_audit",
|
||||
"Parse /etc/security/pwquality.conf and pwquality.conf.d (root "
|
||||
"prefix): minlen below 8, minclass 0, dictcheck=0 and enforcing=0, "
|
||||
"plus world-writable files. Read-only.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"root\":{\"type\":\"string\",\"description\":\"prefix, default empty\"}}}",
|
||||
t_pwquality_audit },
|
||||
};
|
||||
|
||||
const size_t TOOLS_BLUE_N = sizeof(TOOLS_BLUE) / sizeof(TOOLS_BLUE[0]);
|
||||
+100
@@ -8202,6 +8202,95 @@ static void t_harbor_probe(mcp_conn *c, const mcp_json *args, void *user)
|
||||
mcp_buf_free(&b);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------- kafka_connect_probe */
|
||||
|
||||
/* Kafka Connect answers on 8083 with /connectors listing every connector and
|
||||
* /connector-plugins listing every installed plugin. Both are unauthenticated
|
||||
* by default; only the connector list counts as exposure here. */
|
||||
static void t_kafka_connect_probe(mcp_conn *c, const mcp_json *args,
|
||||
void *user)
|
||||
{
|
||||
static const char *paths[] = { "/", "/connectors",
|
||||
"/connector-plugins", NULL };
|
||||
const char *target = mcp_arg_string(args, "target");
|
||||
int port = mcp_arg_int(args, "port", 8083);
|
||||
int tls = mcp_arg_bool(args, "tls", apex_looks_tls(port));
|
||||
mcp_buf b;
|
||||
int first = 1;
|
||||
int tested = 0;
|
||||
int open_count = 0;
|
||||
int connectors_open = 0;
|
||||
char *evidence = NULL;
|
||||
int i;
|
||||
|
||||
(void)user;
|
||||
if (target == NULL || *target == '\0') {
|
||||
mcp_reply_error(c, "target is required");
|
||||
return;
|
||||
}
|
||||
if (port <= 0 || port > 65535) {
|
||||
mcp_reply_error(c, "port out of range");
|
||||
return;
|
||||
}
|
||||
if (!gated(c, "kafka_connect_probe", target, port))
|
||||
return;
|
||||
mcp_buf_init(&b);
|
||||
mcp_buf_puts(&b, "{\"target\":");
|
||||
apex_json_str(&b, target);
|
||||
mcp_buf_printf(&b, ",\"port\":%d,\"tls\":%s,\"endpoints\":[", port,
|
||||
tls ? "true" : "false");
|
||||
for (i = 0; paths[i] != NULL; i++) {
|
||||
char status[256];
|
||||
char *resp = NULL;
|
||||
size_t len = 0;
|
||||
int code;
|
||||
int open;
|
||||
int connectors = strcmp(paths[i], "/connectors") == 0;
|
||||
|
||||
status[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);
|
||||
open = code >= 200 && code < 300;
|
||||
if (open)
|
||||
open_count++;
|
||||
if (open && connectors) {
|
||||
connectors_open = 1;
|
||||
if (evidence == NULL)
|
||||
evidence = apex_evidence_save("kafka-connect-connectors",
|
||||
resp, len);
|
||||
}
|
||||
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}",
|
||||
code, (unsigned long)len, open ? "true" : "false");
|
||||
free(resp);
|
||||
}
|
||||
mcp_buf_printf(&b, "],\"tested\":%d,\"open_count\":%d,"
|
||||
"\"connectors_open\":%s,\"evidence\":",
|
||||
tested, open_count, connectors_open ? "true" : "false");
|
||||
if (evidence != NULL)
|
||||
apex_json_str(&b, evidence);
|
||||
else
|
||||
mcp_buf_puts(&b, "null");
|
||||
mcp_buf_puts(&b, "}");
|
||||
apex_audit("kafka_connect_probe", target, port, !connectors_open,
|
||||
connectors_open
|
||||
? "the Kafka Connect connector list answers without "
|
||||
"authentication"
|
||||
: "the Kafka Connect connector list requires authentication",
|
||||
"list");
|
||||
mcp_reply_json(c, b.p);
|
||||
free(evidence);
|
||||
mcp_buf_free(&b);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- portainer_probe */
|
||||
|
||||
static void t_portainer_probe(mcp_conn *c, const mcp_json *args, void *user)
|
||||
@@ -9097,6 +9186,17 @@ const mcp_tool TOOLS_RED[] = {
|
||||
"\"tls\":{\"type\":\"boolean\"}},"
|
||||
"\"required\":[\"target\"]}",
|
||||
t_portainer_probe },
|
||||
{ "kafka_connect_probe",
|
||||
"Query a Kafka Connect REST API without credentials: /, /connectors "
|
||||
"and /connector-plugins on 8083. A 2xx on /connectors exposes every "
|
||||
"connector and its sink/source configuration, and the body is saved as "
|
||||
"evidence. The worker is unauthenticated by default. Gate: the target.",
|
||||
"{\"type\":\"object\",\"properties\":{"
|
||||
"\"target\":{\"type\":\"string\"},"
|
||||
"\"port\":{\"type\":\"integer\",\"description\":\"default 8083\"},"
|
||||
"\"tls\":{\"type\":\"boolean\"}},"
|
||||
"\"required\":[\"target\"]}",
|
||||
t_kafka_connect_probe },
|
||||
{ "argocd_probe",
|
||||
"Query an Argo CD server without a token: /api/version, "
|
||||
"/api/v1/session/userinfo and /api/v1/applications. A 2xx on the "
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import re
|
||||
import sys
|
||||
|
||||
HERE = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
EXPECTED_TOOLS = 318
|
||||
EXPECTED_TOOLS = 322
|
||||
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.
|
||||
|
||||
+187
-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("318 tools registered", len(tools) == 318, len(tools))
|
||||
check("322 tools registered", len(tools) == 322, 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"]) == 318)
|
||||
check("http tools/list", len(listing["result"]["tools"]) == 322)
|
||||
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
|
||||
@@ -14397,6 +14397,47 @@ argo_auth_srv = http.server.HTTPServer(("127.0.0.1", 0), _ArgoAuthHandler)
|
||||
argo_auth_port = argo_auth_srv.server_address[1]
|
||||
threading.Thread(target=argo_auth_srv.serve_forever, daemon=True).start()
|
||||
|
||||
class _KafkaConnectHandler(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
path = urllib.parse.urlsplit(self.path).path
|
||||
if path == "/":
|
||||
body = b'{"version":"3.7.0","commit":"abc"}'
|
||||
self.send_response(200)
|
||||
elif path == "/connectors":
|
||||
body = b'["s3-sink","jdbc-source"]'
|
||||
self.send_response(200)
|
||||
elif path == "/connector-plugins":
|
||||
body = b'[{"class":"org.apache.kafka.connect.file.FileStreamSink"}'
|
||||
body += b']'
|
||||
self.send_response(200)
|
||||
else:
|
||||
body = b'{"error_code":404,"message":"not found"}'
|
||||
self.send_response(404)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def log_message(self, *args):
|
||||
pass
|
||||
|
||||
class _KafkaConnectAuthHandler(_KafkaConnectHandler):
|
||||
def do_GET(self):
|
||||
body = b'{"error_code":401,"message":"Unauthorized"}'
|
||||
self.send_response(401)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
kc_srv = http.server.HTTPServer(("127.0.0.1", 0), _KafkaConnectHandler)
|
||||
kc_port = kc_srv.server_address[1]
|
||||
threading.Thread(target=kc_srv.serve_forever, daemon=True).start()
|
||||
kc_auth_srv = http.server.HTTPServer(("127.0.0.1", 0),
|
||||
_KafkaConnectAuthHandler)
|
||||
kc_auth_port = kc_auth_srv.server_address[1]
|
||||
threading.Thread(target=kc_auth_srv.serve_forever, daemon=True).start()
|
||||
|
||||
cfg42_home = tempfile.mkdtemp(prefix="apex-cfg42-home-")
|
||||
write_scope(cfg42_home, {"label": "cfg42", "expires": "2099-12-31T23:59:59Z",
|
||||
"allow_private": True, "allow_ip": ["127.0.0.1"],
|
||||
@@ -14475,6 +14516,150 @@ shutil.rmtree(gr_root, ignore_errors=True)
|
||||
shutil.rmtree(gr_good_root, ignore_errors=True)
|
||||
shutil.rmtree(cfg42_home, ignore_errors=True)
|
||||
|
||||
# --- 1.71.0: limits, access.conf and pwquality audits plus the Kafka probe ---
|
||||
print("\n== limits, access.conf, pwquality and Kafka Connect ==")
|
||||
|
||||
lim_root = tempfile.mkdtemp(prefix="apex-lim-")
|
||||
os.makedirs(os.path.join(lim_root, "etc", "security", "limits.d"))
|
||||
lim_bad = os.path.join(lim_root, "etc", "security", "limits.conf")
|
||||
with open(lim_bad, "w") as f:
|
||||
f.write("# limits\n")
|
||||
f.write("* soft nofile unlimited\n")
|
||||
f.write("* hard nproc unlimited\n")
|
||||
f.write("* soft core 4194304\n")
|
||||
f.write("* hard memlock 65536\n")
|
||||
with open(os.path.join(lim_root, "etc", "security", "limits.d",
|
||||
"extra.conf"), "w") as f:
|
||||
f.write("root hard nfs 65536\n")
|
||||
os.chmod(lim_bad, 0o666)
|
||||
|
||||
lim_good_root = tempfile.mkdtemp(prefix="apex-limg-")
|
||||
os.makedirs(os.path.join(lim_good_root, "etc", "security"))
|
||||
with open(os.path.join(lim_good_root, "etc", "security", "limits.conf"),
|
||||
"w") as f:
|
||||
f.write("* soft nofile 1024\n")
|
||||
f.write("* hard nofile 4096\n")
|
||||
f.write("* soft core 0\n")
|
||||
f.write("# * hard nproc unlimited\n")
|
||||
|
||||
ac_root = tempfile.mkdtemp(prefix="apex-ac-")
|
||||
os.makedirs(os.path.join(ac_root, "etc", "security"))
|
||||
ac_bad = os.path.join(ac_root, "etc", "security", "access.conf")
|
||||
with open(ac_bad, "w") as f:
|
||||
f.write("# access\n")
|
||||
f.write("-:ALL EXCEPT root:ALL\n")
|
||||
f.write("+:ALL:ALL\n")
|
||||
os.chmod(ac_bad, 0o666)
|
||||
|
||||
ac_good_root = tempfile.mkdtemp(prefix="apex-acg-")
|
||||
os.makedirs(os.path.join(ac_good_root, "etc", "security"))
|
||||
with open(os.path.join(ac_good_root, "etc", "security", "access.conf"),
|
||||
"w") as f:
|
||||
f.write("-:ALL:ALL\n")
|
||||
f.write("+:root:LOCAL\n")
|
||||
|
||||
pwq_root = tempfile.mkdtemp(prefix="apex-pwq-")
|
||||
os.makedirs(os.path.join(pwq_root, "etc", "security", "pwquality.conf.d"))
|
||||
pwq_bad = os.path.join(pwq_root, "etc", "security", "pwquality.conf")
|
||||
with open(pwq_bad, "w") as f:
|
||||
f.write("minlen = 4\n")
|
||||
f.write("minclass = 0\n")
|
||||
f.write("dictcheck = 0\n")
|
||||
f.write("enforcing = 0\n")
|
||||
f.write("# dcredit = 1\n")
|
||||
os.chmod(pwq_bad, 0o666)
|
||||
|
||||
pwq_good_root = tempfile.mkdtemp(prefix="apex-pwg-")
|
||||
os.makedirs(os.path.join(pwq_good_root, "etc", "security"))
|
||||
with open(os.path.join(pwq_good_root, "etc", "security", "pwquality.conf"),
|
||||
"w") as f:
|
||||
f.write("minlen = 12\n")
|
||||
f.write("minclass = 3\n")
|
||||
f.write("dictcheck = 1\n")
|
||||
f.write("enforcing = 1\n")
|
||||
|
||||
cfg43_home = tempfile.mkdtemp(prefix="apex-cfg43-home-")
|
||||
write_scope(cfg43_home,
|
||||
{"label": "cfg43", "expires": "2099-12-31T23:59:59Z",
|
||||
"allow_private": True, "allow_ip": ["127.0.0.1"],
|
||||
"allow_port": [str(kc_port), str(kc_auth_port)]})
|
||||
res, _ = run([
|
||||
call(1, "limits_audit", root=lim_root),
|
||||
call(2, "limits_audit", root=lim_good_root),
|
||||
call(3, "access_conf_audit", root=ac_root),
|
||||
call(4, "access_conf_audit", root=ac_good_root),
|
||||
call(5, "pwquality_audit", root=pwq_root),
|
||||
call(6, "pwquality_audit", root=pwq_good_root),
|
||||
call(7, "kafka_connect_probe", target="127.0.0.1", port=kc_port,
|
||||
tls=False),
|
||||
call(8, "kafka_connect_probe", target="127.0.0.1", port=kc_auth_port,
|
||||
tls=False),
|
||||
call(9, "kafka_connect_probe", target="198.51.100.9", port=8083),
|
||||
call(10, "limits_audit", root="/nonexistent-lim"),
|
||||
call(11, "access_conf_audit", root="/nonexistent-ac"),
|
||||
call(12, "pwquality_audit", root="/nonexistent-pwq"),
|
||||
], home=cfg43_home)
|
||||
|
||||
by_id = {r.get("id"): r for r in res}
|
||||
|
||||
lim = json.loads(text(by_id[1]))
|
||||
lim_kinds = {f["id"] for f in lim["findings"]}
|
||||
check("limits_audit flags unlimited nofile/nproc and core dumps",
|
||||
{"world-writable", "unlimited-limit", "core-dumps"} <= lim_kinds and
|
||||
lim["files"] == 2, lim)
|
||||
lim_good = json.loads(text(by_id[2]))
|
||||
check("limits_audit accepts finite limits and a commented unlimited line",
|
||||
lim_good["findings_count"] == 0 and lim_good["lines"] == 3, lim_good)
|
||||
|
||||
ac = json.loads(text(by_id[3]))
|
||||
ac_kinds = {f["id"] for f in ac["findings"]}
|
||||
check("access_conf_audit flags allow-all and a default-allow tail",
|
||||
{"world-writable", "allow-all", "default-allow"} <= ac_kinds and
|
||||
ac["allow_all"] is True and ac["rules"] == 2, ac)
|
||||
ac_good = json.loads(text(by_id[4]))
|
||||
check("access_conf_audit accepts deny-all with a restricted allow",
|
||||
ac_good["findings_count"] == 0 and ac_good["allow_all"] is False and
|
||||
ac_good["default_allow"] is False, ac_good)
|
||||
|
||||
pwq = json.loads(text(by_id[5]))
|
||||
pwq_kinds = {f["id"] for f in pwq["findings"]}
|
||||
check("pwquality_audit flags weak minlen, minclass 0, dictcheck=0 and "
|
||||
"enforcing=0",
|
||||
{"world-writable", "weak-minlen", "no-minclass", "no-dictcheck",
|
||||
"not-enforcing"} <= pwq_kinds and pwq["keys"] == 4, pwq)
|
||||
pwq_good = json.loads(text(by_id[6]))
|
||||
check("pwquality_audit accepts a strong password policy",
|
||||
pwq_good["findings_count"] == 0 and pwq_good["weak_minlen"] is False,
|
||||
pwq_good)
|
||||
|
||||
kc = json.loads(text(by_id[7]))
|
||||
check("kafka_connect_probe finds the open connector list",
|
||||
kc["connectors_open"] is True and kc["evidence"] and
|
||||
os.path.isfile(kc["evidence"]) and kc["open_count"] == 3, kc)
|
||||
kc_auth = json.loads(text(by_id[8]))
|
||||
check("kafka_connect_probe reports a protected worker",
|
||||
kc_auth["connectors_open"] is False and kc_auth["evidence"] is None and
|
||||
all(e["status"] == 401 for e in kc_auth["endpoints"]), kc_auth)
|
||||
check("kafka_connect_probe refuses an out-of-scope target", err(by_id[9]),
|
||||
text(by_id[9]))
|
||||
check("limits_audit reports a missing configuration", err(by_id[10]),
|
||||
text(by_id[10]))
|
||||
check("access_conf_audit reports a missing configuration", err(by_id[11]),
|
||||
text(by_id[11]))
|
||||
check("pwquality_audit reports a missing configuration", err(by_id[12]),
|
||||
text(by_id[12]))
|
||||
kc_srv.shutdown()
|
||||
kc_srv.server_close()
|
||||
kc_auth_srv.shutdown()
|
||||
kc_auth_srv.server_close()
|
||||
shutil.rmtree(lim_root, ignore_errors=True)
|
||||
shutil.rmtree(lim_good_root, ignore_errors=True)
|
||||
shutil.rmtree(ac_root, ignore_errors=True)
|
||||
shutil.rmtree(ac_good_root, ignore_errors=True)
|
||||
shutil.rmtree(pwq_root, ignore_errors=True)
|
||||
shutil.rmtree(pwq_good_root, ignore_errors=True)
|
||||
shutil.rmtree(cfg43_home, ignore_errors=True)
|
||||
|
||||
print("\n== esp32 tools ==")
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user