Skip to main content

Module panic_notice

Module panic_notice 

Source
Expand description

The executable’s panic hook: where an internal error happened, never its message. What: The panic hook of the executable: one line naming where an internal error happened, never its message. Why: The linked scanner catches a matcher panic and reports it as a failed scan, but Rust runs the process’s panic hook before the panic can be caught, and the default hook prints the panic’s message, which can hold bytes of the file being scanned. The scanner’s own executable installs a hook that prints nothing; this one keeps the source location, which holds no repository content, so a wrapper defect is still visible.

In TS you’d write (pseudocode):

// process.on('uncaughtException', () => process.stderr.write('cli-git: internal error ...\n'));

Functions§

install_payload_free_panic_hook
What: Make payload_free_panic_hook the process’s panic hook. Box::new(..) puts the named function where the standard library keeps its hook. Why: The executable calls this before anything can scan, as the scanner’s embedding contract requires.
panic_notice
What: The line the hook writes, with the location when the panic has one. Option<&Location<'_>> is “a borrowed location or nothing”; '_ lets the compiler choose how long the borrow lasts. Why: A pure function of the location can be checked exactly.
payload_free_panic_hook
What: The hook itself: write the notice to standard error and nothing else. &PanicHookInfo<'_> borrows what the panic carries; its message is never read. Why: A hook cannot report a failure to write, so a closed stream is ignored.