A lightweight MoonBit Policy-as-Code toolkit for trusted flow governance, boundary rules, and explainable compliance reports.
source request_body "external input"
boundary api_gateway "trusted service boundary"
sanitizer escape_html "html output encoding"
sink render_html "html response renderer"
edge request_body -> api_gateway "ingress"
edge api_gateway -> render_html "response output"
edge api_gateway -> escape_html "encode"
edge escape_html -> render_html "safe render"
deny request_body -> render_html severity=high "raw input must not render directly"
require request_body -> render_html through=escape_html severity=medium "html output must be encoded"
allow request_body -> api_gateway -> escape_html -> render_html "encoded response path"moon add lllg123/moontrustflow# MoonBit 0.10.3+16975d007
moon check --target all --deny-warn
moon test --deny-warn
moon fmt
moon info
moon run cmd/mainpowershell -ExecutionPolicy Bypass -File scripts\analyze_model.ps1 -Path fixtures\models\webapp_taint.mtf -Jsonpython scripts/analyze_model.py fixtures/models/webapp_taint.mtf --jsonpython scripts/import_callgraph.py fixtures/adapters/service_callgraph.jsonpython scripts/benchmark_analysis.py --hops 64python scripts/verify_fixture_corpus.pyMoonTrustFlow policy evaluation
source=embedded-sample
nodes=4, edges=4, policies=3, findings=2moon run cmd/main -- --jsonmoon run cmd/main -- --sarif # SARIF 2.1.0 for security tooling
moon run cmd/main -- --assessment # risk score, graph metrics, and remediation issues
moon run cmd/main -- --graph # human-readable graph and boundary summary
moon run cmd/main -- --contract # deployment-time model contract gatepub(all) struct BaselineComparison {
baseline_count : Int
current_count : Int
new_findings : Array[BaselineFinding]
resolved_findings : Array[BaselineFinding]
unchanged_findings : Array[BaselineFinding]
severity_regressions : Array[BaselineFinding]
passed : Bool
} derive(Eq, ToJson, Debug)pub(all) struct ContractCheck {
kind : ContractCheckKind
name : String
passed : Bool
observed : String
expected : String
detail : String
} derive(Eq, ToJson, Debug)pub(all) struct ContractReport {
contract : String
passed : Bool
checks : Array[ContractCheck]
passed_count : Int
failed_count : Int
} derive(Eq, ToJson, Debug)pub(all) struct FindingExplanation {
kind : ExplanationKind
title : String
summary : String
affected_path : String
risk : String
actions : Array[RemediationAction]
} derive(Eq, ToJson, Debug)pub(all) struct GraphExport {
format : String
nodes : Array[GraphNodeRecord]
edges : Array[GraphEdgeRecord]
digest : String
} derive(Eq, ToJson, Debug)pub(all) struct GraphMetrics {
node_count : Int
edge_count : Int
source_count : Int
sink_count : Int
sanitizer_count : Int
boundary_count : Int
policy_count : Int
reachable_source_count : Int
reachable_sink_count : Int
max_out_degree : Int
max_in_degree : Int
connected_component_count : Int
cycle_hint_count : Int
} derive(Eq, ToJson, Debug)pub(all) struct ModelAssessment {
metrics : GraphMetrics
coverage : PolicyCoverage
issues : Array[ModelIssue]
risk_score : Int
risk_band : RiskBand
recommendation_count : Int
} derive(Eq, ToJson, Debug)pub(all) struct ModelIssue {
kind : ModelIssueKind
subject : String
detail : String
severity : String
recommendation : String
} derive(Eq, ToJson, Debug)pub(all) struct PolicyAudit {
items : Array[PolicyAuditItem]
total : Int
executable : Int
unreachable_count : Int
duplicates : Int
high_risk : Int
coverage_percent : Int
} derive(Eq, ToJson, Debug)pub(all) struct QualityGateResult {
passed : Bool
reasons : Array[String]
assessment : ModelAssessment
policy_audit : PolicyAudit
finding_count : Int
high_finding_count : Int
checked_source_sink_pairs : Int
} derive(Eq, ToJson, Debug)pub(all) struct SarifLocation {
artifact_location : SarifArtifactLocation
logical_regions : Array[SarifRegion]
} derive(Eq, ToJson, Debug)pub(all) struct SarifResult {
rule_id : String
level : String
message : SarifMessage
locations : Array[SarifLocation]
fingerprints : Map[String, String]
} derive(Eq, ToJson, Debug)pub(all) struct SarifRun {
tool : SarifToolWrapper
results : Array[SarifResult]
} derive(Eq, ToJson, Debug)pub(all) struct WorkflowRun {
source : String
model : Model
findings : Array[Finding]
assessment : ModelAssessment
policy_audit : PolicyAudit
quality_gate : QualityGateResult
sarif : String
} derive(Eq, ToJson, Debug)fn compare_baseline(baseline : Array[BaselineFinding], current : Array[Finding]) -> BaselineComparisonfn count_explanations_by_priority(explanations : Array[FindingExplanation], priority : String) -> Intfn workflow_changed_since_baseline(baseline : Array[BaselineFinding], run : WorkflowRun) -> BaselineComparisonA lightweight MoonBit Policy-as-Code toolkit for trusted flow governance, boundary rules, and explainable compliance reports.