Skip to main content

infoflow

Function infoflow 

Source
pub fn infoflow(tenv: &TyEnv) -> Result<(), Diagnostics>
Expand description

Check that no High memory region is mapped at Low.

§Errors

One diagnostic per such mapping, at the mapping.

§Examples

use fic::ast::RawAst;
use fic::foreign::ForeignModules;
use fic::parser::{parse_program, parse_system};
use fic::tast::infoflow::infoflow;

// The check reads the typed tree; the declarations alone type it.
let flows = |label: &str| {
    let system = parse_system("High MemoryRegion secret(0x1000); ProtectionDomain pd1(1);").unwrap();
    let program = parse_program(&format!(r#"{label} Mapping m(secret, "rw");"#)).unwrap();
    // One program per protection domain, by position.
    let rawast = RawAst { system, programs: vec![program] };
    let (env, tenv) = fic::frontend::data_layer(&rawast).unwrap();
    let (rast, _) = fic::rast::build(&rawast, env, &mut ForeignModules::new()).unwrap();
    let (tast, _) = fic::tast::build(rast, tenv).unwrap();
    infoflow(&tast.tenv)
};
assert!(flows("High").is_ok());
assert!(flows("Low").is_err());