Skip to main content

ephemeris_forge_github/api/request/
security.rs

1use facet::Facet;
2
3use crate::{Language, QuerySuite, Reviewer, RunnerType, SetupState, Status, ThreatModel};
4
5/// The state of one security feature in an update body.
6#[derive(Clone, Copy, Debug, Eq, Facet, PartialEq)]
7pub struct StatusBody {
8    /// The wanted state.
9    pub status: Status,
10}
11
12/// The delegated bypass reviewers in an update body.
13#[derive(Clone, Debug, Eq, Facet, PartialEq)]
14pub struct ReviewersBody {
15    /// The complete reviewer set.
16    pub reviewers: Vec<Reviewer>,
17}
18
19/// The managed subset of the `security_and_analysis` update body.
20///
21/// An omitted property leaves the live value alone.
22#[derive(Clone, Debug, Default, Eq, Facet, PartialEq)]
23#[facet(skip_all_unless_truthy)]
24pub struct AnalysisPatch {
25    /// GitHub Advanced Security.
26    pub advanced_security: Option<StatusBody>,
27    /// GitHub Code Security.
28    pub code_security: Option<StatusBody>,
29    /// Secret scanning.
30    pub secret_scanning: Option<StatusBody>,
31    /// Secret scanning push protection.
32    pub secret_scanning_push_protection: Option<StatusBody>,
33    /// AI detection of generic secrets.
34    pub secret_scanning_ai_detection: Option<StatusBody>,
35    /// Scanning for non-provider patterns.
36    pub secret_scanning_non_provider_patterns: Option<StatusBody>,
37    /// Delegated dismissal of secret scanning alerts.
38    pub secret_scanning_delegated_alert_dismissal: Option<StatusBody>,
39    /// Delegated bypass of push protection.
40    pub secret_scanning_delegated_bypass: Option<StatusBody>,
41    /// The reviewers for delegated bypass.
42    pub secret_scanning_delegated_bypass_options: Option<ReviewersBody>,
43}
44
45impl AnalysisPatch {
46    /// Whether the body would carry no property at all.
47    #[must_use]
48    pub fn is_empty(&self) -> bool {
49        *self == Self::default()
50    }
51}
52
53/// The repository update body that carries an [`AnalysisPatch`].
54#[derive(Facet)]
55pub(crate) struct AnalysisBody {
56    pub(crate) security_and_analysis: AnalysisPatch,
57}
58
59/// The managed subset of the code scanning default setup update body.
60#[derive(Clone, Debug, Default, Eq, Facet, PartialEq)]
61#[facet(skip_all_unless_truthy)]
62pub struct CodeScanningPatch {
63    /// Whether default setup runs.
64    pub state: Option<SetupState>,
65    /// The languages to analyze.
66    pub languages: Option<Vec<Language>>,
67    /// Where the analysis runs.
68    pub runner_type: Option<RunnerType>,
69    /// The label of the runner when the runner type is labeled.
70    pub runner_label: Option<String>,
71    /// The set of queries to run.
72    pub query_suite: Option<QuerySuite>,
73    /// The sources treated as untrusted.
74    pub threat_model: Option<ThreatModel>,
75}