cspkit

MoonBit-native Content-Security-Policy parser, auditor, and diff toolkit.

csp
content-security-policy
security
policy-audit
web
moon add ZYK-ai-nb/cspkit@0.1.0
Download zip
Author
Version
0.1.0
License
Apache-2.0
Last updated
4 hours ago
Downloads
3
README

#CSPKit

CSPKit 是一个纯 MoonBit 实现的 Content-Security-Policy 解析、审计与差异分析工具库。它面向 MoonBit WebAssembly 应用、静态站点生成器、安全检查工具、API 网关和教学项目,提供可复用的 CSP 策略处理能力。

#选题独特性

在确定选题前,已检查 Mooncakes 模块列表中的 cspcontent-security-policypermissions-policyfeature-policysecurity.txt 等关键词。其中 cspcontent-security-policy 均为 0 命中。CSPKit 不做通用 HTTP 框架,也不做泛泛的字符串封装,而是聚焦 CSP 这一安全策略文本的解析、风险审计、fallback 计算和策略 diff。

#解决的问题

CSP 能限制脚本、样式、图片、frame 等资源来源,但实际策略经常包含 *'unsafe-inline''unsafe-eval'、缺失 default-src、重复指令、'none' 与其他源混用等问题。CSPKit 把策略字符串解析成结构化数据,并输出可测试、可机器读取的审计结果,帮助 MoonBit 项目在发布前检查安全策略。

#适用场景

  • MoonBit 静态站点或文档工具生成 CSP 时做发布前检查。
  • WebAssembly 网关或边缘服务需要审计响应头。
  • API mock、CI 工具、安全教学项目需要可复现的 CSP 解析示例。
  • 包作者需要不依赖外部运行时的安全策略分析基础库。

#安装

Mooncakes 包名:

ZYK-ai-nb/cspkit

在 MoonBit 项目中添加依赖:

moon add ZYK-ai-nb/cspkit

moon.pkg 中导入:

import {
"ZYK-ai-nb/cspkit" @cspkit
}

#最小使用示例

let policy = @cspkit.parse_policy(
"default-src 'self'; script-src 'self' 'unsafe-inline'",
).unwrap()

let findings = policy.audit()
println(findings.length())
println(policy.blocking_findings().length())

#本地运行

moon check moon build moon test moon run cmd/main

示例输出:

directives=3 blocking=1 added=2 changed=1 header=default-src 'self'; script-src 'self' 'nonce-demo'; object-src 'none'; base-uri 'self'; frame-ancestors 'none' score=100 grade=A penalty=0 bonus=13 templates=23 valid=23 clean=21 risky=2

#核心功能

  • parse_policy:解析 CSP 字符串为 Policy
  • Policy::directive / directives_named / contains:查询指令。
  • Policy::effective_sources:计算 fetch directive 的 default-src fallback。
  • Policy::audit:输出结构化风险 Finding。
  • Policy::blocking_findings:筛选高风险问题。
  • diff_policy:比较两个策略的新增、删除和变更指令。
  • Policy::to_header:输出规范化策略字符串。
  • classify_source_expression:识别 source expression 的类型、信任等级、scheme、host、port 和 path。
  • directive_spec / known_directive_specs:提供 CSP 指令目录、分类和 fallback 元数据。
  • Policy::score:输出策略评分、等级、扣分项和加分项。
  • Policy::hardening_recommendations:生成可机器读取的加固建议。
  • Policy::audit_text_report / audit_markdown_report / audit_json_report:生成文本、Markdown 和可转义的 JSON 审计报告。
  • all_policy_templates:提供静态站点、SPA、WASM、管理后台、支付页、上传页等策略模板。
  • audit_rule_catalog_report:提供审计规则目录和修复说明。

#支持范围

  • CSP 指令按分号拆分,指令名 ASCII 小写规范化。
  • source expression 按 ASCII 空白拆分,保留原始大小写。
  • 识别 'self''none'、nonce、hash、scheme、host、wildcard、data:blob: 等 source expression。
  • 检查重复指令、缺失基线指令、通配符、HTTP 明文源、data: 风险源、'unsafe-inline''unsafe-eval''none' 混用。
  • 对 fetch directives 提供 default-src fallback。
  • 比较两份策略的 added、removed、changed。
  • 按 Finding、source、directive coverage 计算策略分数。
  • 输出文本、Markdown 和 JSON 风格报告。
  • 提供 20 个以上可解析策略模板和规则目录。

#工程规模

当前 MoonBit 源码非空行数为 4390 行,其中去掉 ///// 注释后的非注释代码为 4048 行。核心代码覆盖解析、审计、source 分类、指令目录、评分、报告、模板和规则目录,不使用空函数或无意义代码堆叠。

#暂不支持范围

  • 不解析 HTML meta 标签或网络响应。
  • 不实现浏览器完整 CSP 执行引擎。
  • 不校验 nonce/hash 的真实加密摘要。
  • 不处理 Report-To JSON、HTTP 日期或远程上报。
  • 不包含浏览器兼容性数据库。

#测试与验收命令

moon fmt --check moon info moon check moon check --deny-warn moon build moon test moon test --deny-warn moon run cmd/main moon login moon publish --dry-run

#验收材料索引

#Mooncakes

  • 包名:ZYK-ai-nb/cspkit
  • 当前版本:0.1.0
  • 仓库地址:https://github.com/ZYK-ai-nb/mooncake-auditor-public.git
  • 发布流程:moon login 后执行 moon publish --dry-run,确认通过后执行 moon publish
  • moon.mod 只表示发布元数据已准备好;GitHub 公开同步和 mooncakes.io 发布状态应以对应远端页面为准。

#维护边界

CSPKit 的长期边界是 CSP 策略文本解析、审计、fallback 计算和策略 diff。项目不会扩展成通用 HTTP 框架、浏览器执行引擎或网络扫描器,以保持包体小、测试明确、后续维护成本可控。

#开源许可证与第三方说明

本项目采用 Apache-2.0 许可证。核心代码为 MoonBit 原生实现,不移植第三方源码,不包含图片、音频、字体或来源不明测试数据。

#贡献与安全

#
AuditRuleCategory

pub(all) enum AuditRuleCategory {
RuleBaseline
RuleScript
RuleTransport
RuleEmbedding
RuleLegacy
RuleReporting
RuleSourceSyntax
RuleMaintenance
RuleTrustedTypes
RuleWorker
RuleMedia
RuleNavigation
} derive(Eq,
Debug
)

Catalog category for a CSPKit audit rule.

#
AuditRuleCategory::name

fn AuditRuleCategory::name(self : AuditRuleCategory) -> String

#
AuditRuleSpec

pub(all) struct AuditRuleSpec {
code : String
category : AuditRuleCategory
severity : Severity
directive : String?
trigger : String
remediation : String
rationale : String
} derive(Eq,
Debug
)

Static metadata for audit rules and recommendation mapping.

#
AuditRuleSpec::summary

fn AuditRuleSpec::summary(self : AuditRuleSpec) -> String

#
Directive

pub(all) struct Directive {
name : String
values : Array[String]
order : Int
} derive(Eq,
Debug
)

#
Directive::contains

fn Directive::contains(self : Directive, value : StringView) -> Bool

#
Directive::cryptographic_sources

fn Directive::cryptographic_sources(self : Directive) -> Array[SourceExpression]

#
Directive::dangerous_sources

fn Directive::dangerous_sources(self : Directive) -> Array[SourceExpression]

#
Directive::has_cryptographic_source

fn Directive::has_cryptographic_source(self : Directive) -> Bool

#
Directive::has_dangerous_source

fn Directive::has_dangerous_source(self : Directive) -> Bool

#
Directive::has_network_source

fn Directive::has_network_source(self : Directive) -> Bool

#
Directive::has_source_kind

fn Directive::has_source_kind(self : Directive, kind : SourceExpressionKind) -> Bool

#
Directive::json_line

fn Directive::json_line(self : Directive) -> String

#
Directive::network_sources

fn Directive::network_sources(self : Directive) -> Array[SourceExpression]

#
Directive::source_expressions

fn Directive::source_expressions(self : Directive) -> Array[SourceExpression]

#
Directive::source_summary

fn Directive::source_summary(self : Directive) -> String

#
Directive::to_header

fn Directive::to_header(self : Directive) -> String

#
DirectiveCategory

pub(all) enum DirectiveCategory {
DirectiveFetch
DirectiveDocument
DirectiveNavigation
DirectiveReporting
DirectiveSandbox
DirectiveTrustedTypes
DirectiveUpgrade
DirectiveDeprecated
DirectiveExperimental
DirectiveOther
} derive(Eq,
Debug
)

CSP directive families used by the catalog and reports.

#
DirectiveCategory::is_security_core

fn DirectiveCategory::is_security_core(self : DirectiveCategory) -> Bool

#
DirectiveCategory::name

fn DirectiveCategory::name(self : DirectiveCategory) -> String

#
DirectiveChange

pub(all) struct DirectiveChange {
name : String
before : Array[String]
after : Array[String]
} derive(Eq,
Debug
)

#
DirectiveChange::text_line

fn DirectiveChange::text_line(self : DirectiveChange) -> String

#
DirectiveCoverage

pub(all) struct DirectiveCoverage {
required : Int
present : Int
missing : Array[String]
optional_present : Int
unknown : Int
deprecated : Int
experimental : Int
} derive(Eq,
Debug
)

Coverage for baseline and optional hardening directives.

#
DirectiveCoverage::is_complete

fn DirectiveCoverage::is_complete(self : DirectiveCoverage) -> Bool

#
DirectiveCoverage::summary

fn DirectiveCoverage::summary(self : DirectiveCoverage) -> String

#
DirectiveSpec

pub(all) struct DirectiveSpec {
name : String
category : DirectiveCategory
fallback : String?
repeatable : Bool
level : String
description : String
} derive(Eq,
Debug
)

Metadata for a known CSP directive.

#
DirectiveSpec::has_fallback

fn DirectiveSpec::has_fallback(self : DirectiveSpec) -> Bool

#
DirectiveSpec::is_deprecated

fn DirectiveSpec::is_deprecated(self : DirectiveSpec) -> Bool

#
DirectiveSpec::is_experimental

fn DirectiveSpec::is_experimental(self : DirectiveSpec) -> Bool

#
DirectiveSpec::is_fetch

fn DirectiveSpec::is_fetch(self : DirectiveSpec) -> Bool

#
DirectiveSpec::summary

fn DirectiveSpec::summary(self : DirectiveSpec) -> String

#
Finding

pub(all) struct Finding {
code : String
severity : Severity
directive : String?
message : String
} derive(Eq,
Debug
)

#
Finding::directive_label

fn Finding::directive_label(self : Finding) -> String

#
Finding::is_blocking

fn Finding::is_blocking(self : Finding) -> Bool

#
Finding::json_line

fn Finding::json_line(self : Finding) -> String

#
Finding::markdown_line

fn Finding::markdown_line(self : Finding) -> String

#
Finding::rationale

fn Finding::rationale(self : Finding) -> String

#
Finding::remediation

fn Finding::remediation(self : Finding) -> String

#
Finding::rule_spec

fn Finding::rule_spec(self : Finding) -> AuditRuleSpec?

#
Finding::text_line

fn Finding::text_line(self : Finding) -> String

#
HardeningRecommendation

pub(all) struct HardeningRecommendation {
code : String
priority : RecommendationPriority
directive : String?
summary : String
detail : String
} derive(Eq,
Debug
)

Machine-readable hardening suggestion.

#
HardeningRecommendation::detail_line

fn HardeningRecommendation::detail_line(self : HardeningRecommendation) -> String

#
HardeningRecommendation::json_line

fn HardeningRecommendation::json_line(self : HardeningRecommendation) -> String

#
HardeningRecommendation::markdown_line

fn HardeningRecommendation::markdown_line(self : HardeningRecommendation) -> String

#
HardeningRecommendation::summary_line

fn HardeningRecommendation::summary_line(self : HardeningRecommendation) -> String

#
ParseError

pub(all) enum ParseError {
EmptyPolicy
EmptyDirective
InvalidDirectiveName(name~ : String)
InvalidDirectiveValue(value~ : String)
} derive(Eq,
Debug
)

#
Policy

pub(all) struct Policy {
directives : Array[Directive]
} derive(Eq,
Debug
)

#
Policy::all_sources

fn Policy::all_sources(self : Policy) -> Array[SourceExpression]

#
Policy::allows_any_origin

fn Policy::allows_any_origin(self : Policy) -> Bool

#
Policy::audit

fn Policy::audit(self : Policy) -> Array[Finding]

#
Policy::audit_json_report

fn Policy::audit_json_report(self : Policy) -> String

#
Policy::audit_markdown_report

fn Policy::audit_markdown_report(self : Policy) -> String

#
Policy::audit_text_report

fn Policy::audit_text_report(self : Policy) -> String

#
Policy::blocking_findings

fn Policy::blocking_findings(self : Policy) -> Array[Finding]

#
Policy::contains

fn Policy::contains(self : Policy, name : StringView) -> Bool

#
Policy::cryptographic_sources

fn Policy::cryptographic_sources(self : Policy) -> Array[SourceExpression]

#
Policy::dangerous_sources

fn Policy::dangerous_sources(self : Policy) -> Array[SourceExpression]

#
Policy::deprecated_directives

fn Policy::deprecated_directives(self : Policy) -> Array[Directive]

#
Policy::directive

fn Policy::directive(self : Policy, name : StringView) -> Directive?

#
Policy::directive_catalog_summary

fn Policy::directive_catalog_summary(self : Policy) -> String

#
Policy::directive_coverage

fn Policy::directive_coverage(self : Policy) -> DirectiveCoverage

#
Policy::directives_in_category

fn Policy::directives_in_category(self : Policy, category : DirectiveCategory) -> Array[Directive]

#
Policy::directives_named

fn Policy::directives_named(self : Policy, name : StringView) -> Array[Directive]

#
Policy::document_directives

fn Policy::document_directives(self : Policy) -> Array[Directive]

#
Policy::effective_sources

fn Policy::effective_sources(self : Policy, name : StringView) -> Array[String]?

#
Policy::experimental_directives

fn Policy::experimental_directives(self : Policy) -> Array[Directive]

#
Policy::fetch_directives

fn Policy::fetch_directives(self : Policy) -> Array[Directive]

#
Policy::finding_remediation_report

fn Policy::finding_remediation_report(self : Policy) -> String

#
Policy::hardening_recommendations

fn Policy::hardening_recommendations(self : Policy) -> Array[HardeningRecommendation]

#
Policy::has_source_kind

fn Policy::has_source_kind(self : Policy, kind : SourceExpressionKind) -> Bool

#
Policy::navigation_directives

fn Policy::navigation_directives(self : Policy) -> Array[Directive]

#
Policy::network_sources

fn Policy::network_sources(self : Policy) -> Array[SourceExpression]

#
Policy::recommendation_summary

fn Policy::recommendation_summary(self : Policy) -> String

#
Policy::report

fn Policy::report(self : Policy, flavor : ReportFlavor) -> String

#
Policy::reporting_directives

fn Policy::reporting_directives(self : Policy) -> Array[Directive]

#
Policy::score

fn Policy::score(self : Policy) -> PolicyScore

#
Policy::severity_counts

fn Policy::severity_counts(self : Policy) -> SeverityCounts

#
Policy::source_counts

fn Policy::source_counts(self : Policy) -> SourceCounts

#
Policy::source_inventory_report

fn Policy::source_inventory_report(self : Policy) -> String

#
Policy::source_kind_count

fn Policy::source_kind_count(self : Policy, kind : SourceExpressionKind) -> Int

#
Policy::to_header

fn Policy::to_header(self : Policy) -> String

#
Policy::unknown_directives

fn Policy::unknown_directives(self : Policy) -> Array[Directive]

#
Policy::uses_nonce_or_hash

fn Policy::uses_nonce_or_hash(self : Policy) -> Bool

#
Policy::uses_plain_http

fn Policy::uses_plain_http(self : Policy) -> Bool

#
PolicyDiff

pub(all) struct PolicyDiff {
added : Array[Directive]
removed : Array[Directive]
changed : Array[DirectiveChange]
} derive(Eq,
Debug
)

#
PolicyDiff::change_summary

fn PolicyDiff::change_summary(self : PolicyDiff) -> String

#
PolicyDiff::has_breaking_change

fn PolicyDiff::has_breaking_change(self : PolicyDiff) -> Bool

#
PolicyDiff::markdown_report

fn PolicyDiff::markdown_report(self : PolicyDiff) -> String

#
PolicyDiff::text_report

fn PolicyDiff::text_report(self : PolicyDiff) -> String

#
PolicyGrade

pub(all) enum PolicyGrade {
GradeExcellent
GradeGood
GradeFair
GradeWeak
GradeDangerous
} derive(Eq,
Debug
)

Human-facing grade for the policy score.

#
PolicyGrade::label

fn PolicyGrade::label(self : PolicyGrade) -> String

#
PolicyGrade::name

fn PolicyGrade::name(self : PolicyGrade) -> String

#
PolicyScore

pub(all) struct PolicyScore {
raw_score : Int
final_score : Int
penalty : Int
bonus : Int
grade : PolicyGrade
findings : SeverityCounts
directives : DirectiveCoverage
sources : SourceCounts
} derive(Eq,
Debug
)

Full policy score model.

#
PolicyScore::is_blocked

fn PolicyScore::is_blocked(self : PolicyScore) -> Bool

#
PolicyScore::is_passing

fn PolicyScore::is_passing(self : PolicyScore) -> Bool

#
PolicyScore::json_report

fn PolicyScore::json_report(self : PolicyScore) -> String

#
PolicyScore::markdown_report

fn PolicyScore::markdown_report(self : PolicyScore) -> String

#
PolicyScore::summary

fn PolicyScore::summary(self : PolicyScore) -> String

#
PolicyScore::text_lines

fn PolicyScore::text_lines(self : PolicyScore) -> Array[String]

#
PolicyScore::text_report

fn PolicyScore::text_report(self : PolicyScore) -> String

#
PolicyTemplate

pub(all) struct PolicyTemplate {
name : String
title : String
use_case : String
header : String
notes : String
} derive(Eq,
Debug
)

Named policy template for examples and quick starts.

#
PolicyTemplate::audit_text_report

fn PolicyTemplate::audit_text_report(self : PolicyTemplate) -> String

#
PolicyTemplate::parse

fn PolicyTemplate::parse(self : PolicyTemplate) -> Result[Policy, ParseError]

#
PolicyTemplate::score

#
PolicyTemplate::summary

fn PolicyTemplate::summary(self : PolicyTemplate) -> String

#
RecommendationPriority

pub(all) enum RecommendationPriority {
PriorityInfo
PriorityLow
PriorityMedium
PriorityHigh
PriorityCritical
} derive(Eq,
Debug
)

Priority for a hardening recommendation.

#
RecommendationPriority::name

#
RecommendationPriority::weight

#
ReportFlavor

pub(all) enum ReportFlavor {
ReportText
ReportMarkdown
ReportJson
} derive(Eq,
Debug
)

Output flavor for audit reports.

#
ReportFlavor::name

fn ReportFlavor::name(self : ReportFlavor) -> String

#
Severity

pub(all) enum Severity {
Info
Warning
High
} derive(Eq,
Debug
)

#
Severity::label

fn Severity::label(self : Severity) -> String

#
SeverityCounts

pub(all) struct SeverityCounts {
info : Int
warning : Int
high : Int
total : Int
} derive(Eq,
Debug
)

Aggregated counts by finding severity.

#
SeverityCounts::blocking

fn SeverityCounts::blocking(self : SeverityCounts) -> Int

#
SeverityCounts::nonblocking

fn SeverityCounts::nonblocking(self : SeverityCounts) -> Int

#
SeverityCounts::summary

fn SeverityCounts::summary(self : SeverityCounts) -> String

#
SourceCounts

pub(all) struct SourceCounts {
total : Int
dangerous : Int
network : Int
cryptographic : Int
plain_http : Int
any_origin : Int
data_like : Int
wildcard_host : Int
} derive(Eq,
Debug
)

Aggregated counts for classified CSP source expressions.

#
SourceCounts::has_severe_source_risk

fn SourceCounts::has_severe_source_risk(self : SourceCounts) -> Bool

#
SourceCounts::summary

fn SourceCounts::summary(self : SourceCounts) -> String

#
SourceExpression

pub(all) struct SourceExpression {
raw : String
normalized : String
kind : SourceExpressionKind
trust : SourceTrust
scheme : String?
host : String?
port : String?
path : String?
description : String
} derive(Eq,
Debug
)

Structured information derived from a raw CSP source expression.

#
SourceExpression::allows_any_origin

fn SourceExpression::allows_any_origin(self : SourceExpression) -> Bool

#
SourceExpression::allows_data_like_url

fn SourceExpression::allows_data_like_url(self : SourceExpression) -> Bool

#
SourceExpression::detail

fn SourceExpression::detail(self : SourceExpression) -> String

#
SourceExpression::has_port

fn SourceExpression::has_port(self : SourceExpression) -> Bool

#
SourceExpression::has_scheme

fn SourceExpression::has_scheme(self : SourceExpression) -> Bool

#
SourceExpression::is_cryptographic

fn SourceExpression::is_cryptographic(self : SourceExpression) -> Bool

#
SourceExpression::is_dangerous

fn SourceExpression::is_dangerous(self : SourceExpression) -> Bool

#
SourceExpression::is_dynamic

fn SourceExpression::is_dynamic(self : SourceExpression) -> Bool

#
SourceExpression::is_empty

fn SourceExpression::is_empty(self : SourceExpression) -> Bool

#
SourceExpression::is_host_with_path

fn SourceExpression::is_host_with_path(self : SourceExpression) -> Bool

#
SourceExpression::is_keyword

fn SourceExpression::is_keyword(self : SourceExpression) -> Bool

#
SourceExpression::is_local_like

fn SourceExpression::is_local_like(self : SourceExpression) -> Bool

#
SourceExpression::is_network_source

fn SourceExpression::is_network_source(self : SourceExpression) -> Bool

#
SourceExpression::is_wildcard_host

fn SourceExpression::is_wildcard_host(self : SourceExpression) -> Bool

#
SourceExpression::json_line

fn SourceExpression::json_line(self : SourceExpression) -> String

#
SourceExpression::summary

fn SourceExpression::summary(self : SourceExpression) -> String

#
SourceExpression::uses_plain_http

fn SourceExpression::uses_plain_http(self : SourceExpression) -> Bool

#
SourceExpressionKind

pub(all) enum SourceExpressionKind {
SourceEmpty
SourceNone
SourceSelf
SourceUnsafeInline
SourceUnsafeEval
SourceWasmUnsafeEval
SourceStrictDynamic
SourceUnsafeHashes
SourceReportSample
SourceNonce
SourceSha256
SourceSha384
SourceSha512
SourceScheme
SourceHost
SourceWildcard
SourceData
SourceBlob
SourceFilesystem
SourceMediastream
SourceHttpsScheme
SourceHttpScheme
SourceUpgradeKeyword
SourceUnknownKeyword
SourceUnknown
} derive(Eq,
Debug
)

Classification for a single CSP source expression.

#
SourceExpressionKind::name

fn SourceExpressionKind::name(self : SourceExpressionKind) -> String

#
SourceTrust

pub(all) enum SourceTrust {
TrustBlocksAll
TrustSameOrigin
TrustCryptographic
TrustExplicitOrigin
TrustTransportScheme
TrustDynamic
TrustDangerous
TrustUnknown
} derive(Eq,
Debug
)

Coarse trust bucket used by reports and scoring.

#
SourceTrust::name

fn SourceTrust::name(self : SourceTrust) -> String

#
admin_panel_template

fn admin_panel_template() -> PolicyTemplate

#
all_policy_templates

fn all_policy_templates() -> Array[PolicyTemplate]

#
analytics_limited_template

fn analytics_limited_template() -> PolicyTemplate

#
api_console_template

fn api_console_template() -> PolicyTemplate

#
audit_rule_catalog_report

fn audit_rule_catalog_report() -> String

#
audit_rule_catalog_summary

fn audit_rule_catalog_summary() -> String

#
audit_rule_spec_by_code

fn audit_rule_spec_by_code(code : StringView) -> AuditRuleSpec?

#
audit_rules_by_category

fn audit_rules_by_category(category : AuditRuleCategory) -> Array[AuditRuleSpec]

#
audit_rules_by_severity

fn audit_rules_by_severity(severity : Severity) -> Array[AuditRuleSpec]

#
baseline_audit_rule_specs

fn baseline_audit_rule_specs() -> Array[AuditRuleSpec]

#
classify_source_expression

fn classify_source_expression(raw : StringView) -> SourceExpression

#
compare_policy_templates

fn compare_policy_templates(before_name : StringView, after_name : StringView) -> PolicyDiff?

#
deprecated_directive_names

fn deprecated_directive_names() -> Array[String]

#
diff_policy

fn diff_policy(before : Policy, after : Policy) -> PolicyDiff

#
directive_category

fn directive_category(name : StringView) -> DirectiveCategory

#
directive_fallback_parent

fn directive_fallback_parent(name : StringView) -> String?

#
directive_spec

fn directive_spec(name : StringView) -> DirectiveSpec?

#
document_directive_names

fn document_directive_names() -> Array[String]

#
embedded_widget_template

fn embedded_widget_template() -> PolicyTemplate

#
extended_audit_rule_specs

fn extended_audit_rule_specs() -> Array[AuditRuleSpec]

#
fetch_directive_names

fn fetch_directive_names() -> Array[String]

#
hardening_directive_names

fn hardening_directive_names() -> Array[String]

#
is_known_directive_name

fn is_known_directive_name(name : StringView) -> Bool

#
known_directive_catalog_report

fn known_directive_catalog_report() -> String

#
known_directive_names

fn known_directive_names() -> Array[String]

#
known_directive_specs

fn known_directive_specs() -> Array[DirectiveSpec]

#
known_directives_by_category

fn known_directives_by_category(category : DirectiveCategory) -> Array[DirectiveSpec]

#
legacy_audit_rule_specs

fn legacy_audit_rule_specs() -> Array[AuditRuleSpec]

#
legacy_cdn_template

fn legacy_cdn_template() -> PolicyTemplate

#
local_dev_template

fn local_dev_template() -> PolicyTemplate

#
locked_down_document_template

fn locked_down_document_template() -> PolicyTemplate

#
locked_iframe_template

fn locked_iframe_template() -> PolicyTemplate

#
markdown_preview_template

fn markdown_preview_template() -> PolicyTemplate

#
media_library_template

fn media_library_template() -> PolicyTemplate

fn navigation_directive_names() -> Array[String]

#
no_script_report_template

fn no_script_report_template() -> PolicyTemplate

#
nonce_spa_template

fn nonce_spa_template() -> PolicyTemplate

#
offline_docs_template

fn offline_docs_template() -> PolicyTemplate

#
parse_policy

fn parse_policy(input : StringView) -> Result[Policy, ParseError]

#
payment_checkout_template

fn payment_checkout_template() -> PolicyTemplate

#
policy_template_by_name

fn policy_template_by_name(name : StringView) -> PolicyTemplate?

#
policy_template_names

fn policy_template_names() -> Array[String]

#
production_spa_template

fn production_spa_template() -> PolicyTemplate

#
recommendation_weight_total

fn recommendation_weight_total(items : Array[HardeningRecommendation]) -> Int

#
recommendations_by_priority

fn recommendations_by_priority(items : Array[HardeningRecommendation], priority : RecommendationPriority) -> Array[HardeningRecommendation]

#
report_only_migration_template

fn report_only_migration_template() -> PolicyTemplate

#
reporting_audit_rule_specs

fn reporting_audit_rule_specs() -> Array[AuditRuleSpec]

#
reporting_directive_names

fn reporting_directive_names() -> Array[String]

#
riskiest_policy_template

fn riskiest_policy_template() -> PolicyTemplate?

#
safest_policy_template

fn safest_policy_template() -> PolicyTemplate?

#
script_audit_rule_specs

fn script_audit_rule_specs() -> Array[AuditRuleSpec]

#
service_worker_template

fn service_worker_template() -> PolicyTemplate

#
source_audit_rule_specs

fn source_audit_rule_specs() -> Array[AuditRuleSpec]

#
source_scheme_tail

fn source_scheme_tail(raw : StringView) -> String

#
strict_api_docs_template

fn strict_api_docs_template() -> PolicyTemplate

#
strict_static_site_template

fn strict_static_site_template() -> PolicyTemplate

#
template_audit_reports

fn template_audit_reports() -> String

#
template_catalog_summary

fn template_catalog_summary() -> String

#
template_scoreboard

fn template_scoreboard() -> String

#
templates_with_high_findings

fn templates_with_high_findings() -> Array[PolicyTemplate]

#
templates_without_high_findings

fn templates_without_high_findings() -> Array[PolicyTemplate]

#
transport_audit_rule_specs

fn transport_audit_rule_specs() -> Array[AuditRuleSpec]

#
trusted_types_app_template

fn trusted_types_app_template() -> PolicyTemplate

#
trusted_types_audit_rule_specs

fn trusted_types_audit_rule_specs() -> Array[AuditRuleSpec]

#
upload_portal_template

fn upload_portal_template() -> PolicyTemplate

#
valid_policy_templates

fn valid_policy_templates() -> Array[PolicyTemplate]

#
wasm_app_template

fn wasm_app_template() -> PolicyTemplate

#
worker_compute_template

fn worker_compute_template() -> PolicyTemplate