Skip to content

Commit

Permalink
fix,feat(postbuildstepper): typo in cdunster, add trusted users per-org
Browse files Browse the repository at this point in the history
  • Loading branch information
steveej committed Dec 16, 2024
1 parent ef0558b commit 4eb955f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 18 deletions.
65 changes: 48 additions & 17 deletions applications/postbuildstepper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub mod business {
use anyhow::{anyhow, bail, Context, Result};
use core::time;
use log::{debug, info, trace, warn};
use reqwest::header::{AUTHORIZATION, USER_AGENT};
use reqwest::header::USER_AGENT;
use serde_json::json;
use std::{
collections::{HashMap, HashSet},
Expand Down Expand Up @@ -287,26 +287,57 @@ pub mod business {

/// Verifies that the build current owners are trusted.
// FIXME: make trusted owners configurable
pub fn check_owners(owners: HashSet<String>) -> anyhow::Result<()> {
pub fn check_owners(owners: HashSet<String>, org: &str, _repo: &str) -> anyhow::Result<()> {
const TRUSTED_OWNERS: &[&str] = &[
// bots
"github-actions",
// admins
"steveej",
"Stefan Junker <[email protected]>",
"evangineer",
// devs
"ThetaSinner",
"cduster",
"zippy",
"JettTech",
"mattgeddes",
"zeeshan595",
"zo-el",
];
let trusted_owners =
HashSet::<String>::from_iter(TRUSTED_OWNERS.iter().map(ToString::to_string));
let owner_is_trusted = owners.is_subset(&trusted_owners);

const TRUSTED_OWNERS_PER_ORG: &[(&str, &[&str])] = &[
(
"holochain",
&[
// admins
"steveej",
"Stefan Junker <[email protected]>",
"evangineer",
// devs
"ThetaSinner",
"cdunster",
"zippy",
],
),
(
"holo-host",
&[
"steveej",
"Stefan Junker <[email protected]>",
"evangineer",
"JettTech",
"mattgeddes",
"zeeshan595",
"mattgeddes",
],
),
];

let mut trusted_owners = HashSet::<&&str>::from_iter(TRUSTED_OWNERS.iter());
trusted_owners.extend(
HashMap::<&str, HashSet<&&str>>::from_iter(
TRUSTED_OWNERS_PER_ORG
.iter()
.map(|(k, v)| (*k, HashSet::from_iter(v.iter()))),
)
.get(org)
.cloned()
.unwrap_or_default(),
);
let owner_is_trusted = owners.is_subset(
&trusted_owners
.into_iter()
.map(ToString::to_string)
.collect(),
);
if !owner_is_trusted {
bail!("{owners:?} are *NOT* trusted!");
}
Expand Down
4 changes: 3 additions & 1 deletion applications/postbuildstepper/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ async fn main() -> anyhow::Result<()> {

let build_info = business::BuildInfo::from_env();

business::check_owners(build_info.try_owners()?)?;
let (org, repo) = build_info.try_org_repo()?;

business::check_owners(build_info.try_owners()?, org, repo)?;

let SigningAndCopyInfo {
signing_key_file,
Expand Down

0 comments on commit 4eb955f

Please sign in to comment.