fix(sec-core): parse loongshield harden output#843
Merged
edonyzpc merged 3 commits intoJun 11, 2026
Merged
Conversation
c1a07a4 to
28bd01c
Compare
edonyzpc
reviewed
Jun 11, 2026
edonyzpc
requested changes
Jun 11, 2026
RemindD
approved these changes
Jun 11, 2026
0c406eb
into
alibaba:release/agent-sec-core/v0.6.0
15 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Update
agent-sec-cli hardenparsing to handle the current loongshield seharden output formats, including verboseSummary:lines andFAIL [rule_id]rule records. The hardening summary now displays compliance when a non-compliant scan exits non-zero but still emits parseable rule statistics, while avoiding reinforce suggestions for syntheticUNKNOWNparser-fallback failures. Security events now also preserve the command success/failure state at the top-level event result while keeping parsed seharden details underdetails.result.Output Examples
Representative loongshield 1.2.1 verbose scan output:
The scan above may exit non-zero because the host is non-compliant. The security event keeps that command state at the top level, while preserving parsed seharden details under
details.result:[ { "event_type": "harden", "category": "hardening", "result": "failed", "details": { "request": { "args": ["--scan", "--config", "agentos_baseline", "--verbose"] }, "result": { "mode": "scan", "config": "agentos_baseline", "returncode": 1, "passed": 20, "fixed": 0, "failed": 3, "manual": 0, "dry_run_pending": 0, "total": 23, "failures": [ { "rule_id": "fs.udf_disabled", "status": "FAIL", "message": "Ensure mounting of udf is disabled" } ], "fixed_items": [] } } } ]agent-sec-cli events --summaryconsumes the same security event data and can now report compliance even when the scan event itself isfailed:If loongshield only emits summary counts but per-rule details cannot be parsed, the backend records a synthetic
UNKNOWNfailure. In that case the summary still shows compliance, but does not suggestharden --reinforcebecause there is no actionable parsed rule id.Related Issue
no-issue: compatibility fix for loongshield 1.2.1 hardening output
Type of Change
Scope
cosh(copilot-shell)sec-core(agent-sec-core)skill(os-skills)sight(agentsight)tokenless(tokenless)ckpt(ws-ckpt)memory(agent-memory)anolisa(anolisa-cli)Checklist
cosh: Lint passes, type check passes, and tests passsec-core(Rust):cargo clippy -- -D warningsandcargo fmt --checkpasssec-core(Python): Ruff format and pytest passskill: Skill directory structure is valid and shell scripts pass syntax checksight:cargo clippy -- -D warningsandcargo fmt --checkpasstokenless:cargo clippy -- -D warningsandcargo fmt --checkpassmemory(Linux only):cargo clippy --all-targets -- -D warnings,cargo fmt --check, andcargo testpassanolisa:cargo clippy --all-targets --locked -- -D warnings,cargo fmt --all --check, andcargo test --lockedpasspackage-lock.json/Cargo.lock)Testing
cd src/agent-sec-core && uv run --project agent-sec-cli pytest tests/unit-test/security_middleware/test_lifecycle.py tests/unit-test/security_middleware/backends/test_hardening_backend.py tests/unit-test/security_events/test_summary_formatter.py -qcd src/agent-sec-core && uv run --project agent-sec-cli pytest tests/e2e/cli/test_events_e2e.py --collect-only -qcd src/agent-sec-core && uv run --project agent-sec-cli ruff check agent-sec-cli/src/agent_sec_cli/security_middleware/lifecycle.py agent-sec-cli/src/agent_sec_cli/security_middleware/backends/hardening.py agent-sec-cli/src/agent_sec_cli/security_events/summary_formatter.py tests/unit-test/security_middleware/test_lifecycle.py tests/unit-test/security_middleware/backends/test_hardening_backend.py tests/unit-test/security_events/test_summary_formatter.py tests/e2e/cli/test_events_e2e.pycd src/agent-sec-core && uv run --project agent-sec-cli black --check agent-sec-cli/src/agent_sec_cli/security_middleware/lifecycle.py agent-sec-cli/src/agent_sec_cli/security_middleware/backends/hardening.py agent-sec-cli/src/agent_sec_cli/security_events/summary_formatter.py tests/unit-test/security_middleware/test_lifecycle.py tests/unit-test/security_middleware/backends/test_hardening_backend.py tests/unit-test/security_events/test_summary_formatter.py tests/e2e/cli/test_events_e2e.py