0.1.0-0-pre.7
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
# file: scripts/audit_rust_general_rules.py
|
||||
# version: 1
|
||||
# version: 2
|
||||
|
||||
"""Audit mechanically verifiable Rust normalization rules used by games.sasedev."""
|
||||
|
||||
@@ -513,9 +513,18 @@ def audit_file(root: pathlib.Path, path: pathlib.Path) -> list[Violation]:
|
||||
violations.append(Violation("RUST-IMPORT-114", relative, current_idx, "module use block is not alphabetically ordered"))
|
||||
# Crate façade constraints.
|
||||
if path.name in {"lib.rs", "main.rs"}:
|
||||
for attribute in ("#![warn(missing_docs)]", "#![deny(unreachable_pub)]", "#![forbid(unsafe_code)]"):
|
||||
ffi_export_exception = relative == "crates/apps/game-android-entrypoint/src/lib.rs"
|
||||
required_attributes = ["#![warn(missing_docs)]", "#![deny(unreachable_pub)]"]
|
||||
required_attributes.append("#![allow(unsafe_code)]" if ffi_export_exception else "#![forbid(unsafe_code)]")
|
||||
for attribute in required_attributes:
|
||||
if attribute not in lines[:24]:
|
||||
violations.append(Violation("RUST-BASE-103", relative, 1, f"missing `{attribute}`"))
|
||||
if ffi_export_exception:
|
||||
export_attribute = '#[unsafe(export_name = "SDL_main")]'
|
||||
if text.count(export_attribute) != 1:
|
||||
violations.append(Violation("RUST-FFI-101", relative, 1, "Android entrypoint must contain exactly one SDL_main export attribute"))
|
||||
if "unsafe {" in text or re.search(r"\bunsafe\s+fn\b", text) is not None or re.search(r"\bunsafe\s+extern\b", text) is not None:
|
||||
violations.append(Violation("RUST-FFI-102", relative, 1, "Android entrypoint exception permits an unsafe export attribute only; unsafe blocks/functions remain forbidden"))
|
||||
exports: list[tuple[int, str]] = []
|
||||
for idx, line in enumerate(lines, 1):
|
||||
stripped = line.strip()
|
||||
|
||||
Reference in New Issue
Block a user