Runtime Policy Deep Dive
This page explains runtime control-plane policy in VulnParse-Pin: path/file policy (PFH), logging policy, and run context/service wiring.
Scope
Primary implementation files:
src/vulnparse_pin/app/bootstrap.pysrc/vulnparse_pin/core/classes/dataclass.pysrc/vulnparse_pin/io/pfhandler.pysrc/vulnparse_pin/utils/logger.pysrc/vulnparse_pin/cli/args.py
Runtime bootstrap sequence
initialize_runtime(args) assembles the runtime in this order:
- Resolve app paths (
AppPaths.resolve(...)). - Initialize bootstrap logger.
- Initialize
PermFileHandlerwith root and symlink policy. - Build initial
RunContext. - Ensure/load configs.
- Load scoring and TopN policy objects.
- Build
FeedCacheManagerand optionalNVDFeedCache. - Build immutable
Servicescontainer. - Rebind logger to run-specific log file.
- Build pass list (
ScoringPass,TopNPass,SummaryPass).
Run context and services
RunContext is the runtime dependency object passed through parsing, enrichment, and pass execution.
RunContext fields:
pathspfhloggerservices
Services fields:
feed_cachenvd_cachescoring_configtopn_config
RunContext and Services are frozen dataclasses to prevent accidental mutation after assembly.
PFH policy (PermFileHandler)
PFH centralizes path validation and safe file operations.
Policy controls
Constructor policy controls include:
- allowed root set
forbid_symlinks_readforbid_symlinks_writeenforce_roots_on_readenforce_roots_on_writefile_mode(POSIX)dir_mode(POSIX)
Typical enforcement
- Read path: readable regular file and optional root confinement.
- Write path: writable target and enforced root confinement by default.
- Symlink handling: write symlinks forbidden by default.
Runtime diagnostics
--debug-path-policy prints policy (describe_policy()) and exits.
CLI flags for PFH/runtime security
Path policy flags are defined in cli/args.py:
--forbid-symlinks-read--forbid-symlinks-write--enforce-root-read--enforce-root-write--file-mode--dir-mode--debug-path-policy
These values are injected directly into PermFileHandler during bootstrap.
Logging policy (LoggerWrapper)
LoggerWrapper sets up two handlers:
- File handler at
DEBUGlevel. - Console handler at selected CLI log level.
Logging channels
vulnparselogger: console + filevulnparse.fileonlylogger: file only
Formats and labels
- Console: colored level tags and icons.
- File: timestamped plain text with ANSI stripped.
- Label propagation through
VulnParseRecordFilter(vp_labeltolabel).
Custom level
A SUCCESS level (25) is registered between INFO and WARNING for status reporting.
Run log resolution
Run logs are generated by build_run_log(...) and created in paths.log_dir with timestamp-based names.
Bootstrap starts with bootstrap.log, then transitions to a run-specific log file after runtime context initialization.
Policy interactions
- PFH gates file-system access for cache, output, and log operations.
- Logger captures policy decisions and fallback behavior.
RunContextensures every subsystem receives the same policy instances.- Services object controls policy consistency for pass and enrichment execution.
Operational tuning guidance
- Keep
--enforce-root-writeenabled for production workloads. - Keep
--forbid-symlinks-writeenabled unless there is a controlled operational exception. - Increase log level from
INFOtoWARNINGorERRORfor very large runs to reduce log overhead. - Use
--debug-path-policywhen validating deployment hardening before first production run.