Streaming ANSI/ECMA-48 terminal log sanitizer and security auditor for MoonBit
moon add DWS-ai-nb/termproofimport {
"DWS-ai-nb/termproof" @termproof
}fn main {
let log = "ok\u{1b}[32mPASS\u{1b}[0m\n" +
"copy\u{1b}]52;c;SGVsbG8=\u{7}\n"
let result = @termproof.audit(log, policy=@termproof.Policy::strict())
println(@termproof.summary_line(result))
println(@termproof.profile_summary(result.profile()))
println(@termproof.remediation_summary(result))
println(result.plain_text)
}moon run cmd/termproof -- demomoon run examples/audit
moon run examples/overviewmoon run cmd/termproof -- audit "trusted output" --policy strictmoon run cmd/termproof -- audit "trusted output" --format markdownmoon run cmd/termproof -- clean "trusted output" --policy plainmoon run cmd/termproof -- events "trusted output"moon run cmd/termproof -- overview "trusted output" --format markdownlet overview = @termproof.audit_overview("safe\nbad\u{1b}[2J")
println(@termproof.overview_summary(overview))
println(@termproof.overview_markdown(overview))| Policy | Intended use | Keeps SGR colors | Keeps OSC 8 links | Marks dangerous data | Fails at |
|---|---|---|---|---|---|
| strict | review and artifact publishing | no | no | yes | dangerous |
| ci | CI logs that may keep colors | yes | no | no | critical |
| plain | irreversible text export | no | no | no | critical |
| permissive | diagnostics and migration | yes | yes, except high-risk schemes | no | critical |
moon check --deny-warn
moon fmt --check
moon build
moon test --deny-warn
moon run examples/audit
moon run cmd/termproof -- audit "trusted output" --policy strict
moon info
moon package --listmoon login
moon package --list
moon publish --frozenpub(all) struct AuditOverview {
result : AuditResult
profile : AuditProfile
remediation : RemediationPlan
line_index : LineIndex
located : Array[LocatedFinding]
line_risks : Array[LineRisk]
} derive(Eq, Debug)pub(all) struct AuditProfile {
total_findings : Int
total_events : Int
text_chars : Int
control_events : Int
severity : SeverityTally
decisions : DecisionTally
risks : Array[RiskTally]
rules : Array[RuleTally]
highest_severity : Severity
score : ProfileScore
} derive(Eq, Debug)pub(all) struct LocatedFinding {
finding : Finding
position : SourcePosition
line_text : String
caret : String
} derive(Eq, Debug)pub(all) struct Parser {
mode : ParserMode
text : Array[Char]
sequence : Array[Char]
payload : Array[Char]
sequence_limit : Int
sequence_truncated : Bool
sequence_start : Int
offset : Int
}pub(all) struct Remediation {
rule_id : String
risk : RiskKind
severity : Severity
priority : ActionPriority
title : String
why : String
immediate : String
safe_default : String
long_term : String
} derive(Eq, Debug)pub(all) struct RemediationPlan {
summary : String
gate : String
blocked : Bool
actions : Array[Remediation]
next_steps : Array[String]
} derive(Eq, Debug)fn github_property_escape(input : String) -> Stringfn starts_with_ascii_case_insensitive(input : String, prefix : String) -> Boolfn visible(input : String) -> StringInstall
Download zipStreaming ANSI/ECMA-48 terminal log sanitizer and security auditor for MoonBit