luct_scanner/config.rs
1use derive_builder::Builder;
2use serde::{Deserialize, Serialize};
3use web_time::Duration;
4
5/// Configuration values of the [`ScannerConfig`].
6///
7/// These values determine, how the [`Scanner`](crate::Scanner) behaves.
8#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Builder)]
9#[builder(setter(into))]
10pub struct ScannerConfig {
11 /// Set whether the certificate chain should be validated by the scanner
12 ///
13 /// This is generally not necessary inside a browser, as the chain has already
14 /// been validated by the browser, but e.g. it might make sense when fetching the
15 /// chain from a file system.
16 #[builder(default)]
17 pub(crate) validate_cert_chain: bool,
18
19 /// A STH that is younger than this time is considered fresh an STH that is older mature
20 ///
21 /// The policy evaluation requires a fresh STH to show that the log is still active
22 /// If the STH against which the inclusion proof has been made is mature, it will not require
23 /// additional STH validations
24 #[builder(default = "Duration::from_secs(60 * 60 * 24)")]
25 pub(crate) sth_freshness_threshold: Duration,
26
27 /// If the logs newest STH is older than this time, it will attempt to fetch a fresher value
28 ///
29 /// This value must not be larger than `sth_freshness_theshold`
30 #[builder(default = "Duration::from_secs(60 * 60 * 8)")]
31 pub(crate) sth_update_threshold: Duration,
32}
33
34impl ScannerConfig {
35 /// Return a [`ScannerConfigBuilder`]
36 pub fn builder() -> ScannerConfigBuilder {
37 ScannerConfigBuilder::default()
38 }
39
40 /// Returns `true`, if certificate chain validation is activated
41 pub fn validate_cert_chain(&self) -> bool {
42 self.validate_cert_chain
43 }
44}