feat(agent-call): implement remediation plan

This commit is contained in:
2026-09-13 19:20:28 +08:00
parent d30314c7d1
commit b95d2aee81
25 changed files with 3159 additions and 535 deletions
+10 -6
View File
@@ -61,9 +61,7 @@ def build(cfg, image, password, config_gid=1000, template=None, environment=None
f"ASTERISK_IMAGE={shlex.quote(image)}",
f"ASTERISK_CONFIG_GID={config_gid}",
]
variables.extend(
f"{key}={shlex.quote(value)}" for key, value in payloads.items()
)
variables.extend(f"{key}={shlex.quote(value)}" for key, value in payloads.items())
variables.append("")
if template is None:
template = Path(__file__).with_name("asterisk_bootstrap.sh")
@@ -76,7 +74,9 @@ def build(cfg, image, password, config_gid=1000, template=None, environment=None
def write_output(content, path):
path = Path(path)
if path.exists() or path.is_symlink():
raise ValueError("output already exists; choose a new local secret-bearing path")
raise ValueError(
"output already exists; choose a new local secret-bearing path"
)
path.parent.mkdir(parents=True, exist_ok=True)
temporary_path = None
try:
@@ -105,7 +105,9 @@ def main():
parser.add_argument("--config", required=True, help="render_asterisk JSON config")
parser.add_argument("--image", help="immutable registry image@sha256:digest")
parser.add_argument("--ari-password-file")
parser.add_argument("--output", required=True, help="local secret-bearing user-data path")
parser.add_argument(
"--output", required=True, help="local secret-bearing user-data path"
)
parser.add_argument("--config-gid", type=int, default=1000)
args = parser.parse_args()
try:
@@ -113,7 +115,9 @@ def main():
image = immutable_image(
args.image or cfg.get("asterisk_image") or os.environ.get("ASTERISK_IMAGE")
)
content = build(cfg, image, read_secret(args.ari_password_file), args.config_gid)
content = build(
cfg, image, read_secret(args.ari_password_file), args.config_gid
)
if len(content.encode()) > 16 * 1024:
raise ValueError("generated user-data exceeds the ECS 16 KiB limit")
write_output(content, args.output)