cypat/lib.rs
1/*
2* SPDX-License-Identifier: GPL-3.0-only
3* A cyberpatriots scoring engine library
4* Copyright (C) 2023 Teresa Maria Rivera
5*/
6
7//! A cyberpatriots scoring engine library
8//!
9//! Provides a fairly simple interface for programming Cyberpatriots scoring engines for practice images.
10//! It provides many core facilities useful for writing a scoring engine,
11//! such as a simple system to handle vulnerabilities, a scoring report,
12//! and some optional facilities for handling a database of configuration files,
13//! or providing utilities for users, groups and packages.
14//!
15//! ## Examples
16//!
17//! Here's an example of a stupidly simple scoring engine.
18//! ```rust
19//! fn main() {
20//! let mut engine = cypat::Engine::new();
21//! engine.add_file_vuln("world.txt", move |e, x| -> bool {
22//! match x {
23//! Some(file) => {
24//! let mut string: std::string::String;
25//! std::io::BufReader::new(file.clone()).read_line(&mut string);
26//!
27//! if string == "Hello World" {
28//! e.add_score_entry(0, 50, "Wrote Hello World.".to_string());
29//! true
30//! } else {
31//! false
32//! }
33//! },
34//! None => false,
35//! }
36//! });
37//!
38//! engine.add_hook(|x| {
39//! if x.entry_exists(0) {
40//! x.stop(false);
41//! }
42//! });
43//!
44//! engine.set_freq(2);
45//! engine.set_completed_freq(10);
46//! engine.enter();
47//! }
48//! ```
49
50mod engine;
51pub use engine::*;
52
53#[cfg(feature = "utility")]
54pub mod util;