diff --git a/clomonitor-core/src/linter/checks/openssf_badge.rs b/clomonitor-core/src/linter/checks/openssf_badge.rs index 0cad6209..e5c22f19 100644 --- a/clomonitor-core/src/linter/checks/openssf_badge.rs +++ b/clomonitor-core/src/linter/checks/openssf_badge.rs @@ -19,14 +19,19 @@ pub(crate) const CHECK_SETS: [CheckSet; 1] = [CheckSet::Code]; lazy_static! { #[rustfmt::skip] static ref OPENSSF_URL: Regex = Regex::new( - r"(https://bestpractices.coreinfrastructure.org/projects/\d+)", + r"(https://www.bestpractices.dev/projects/\d+)", ).expect("exprs in OPENSSF_URL to be valid"); + + #[rustfmt::skip] + static ref OPENSSF_URL_LEGACY: Regex = Regex::new( + r"(https://bestpractices.coreinfrastructure.org/projects/\d+)", + ).expect("exprs in OPENSSF_URL_LEGACY to be valid"); } /// Check main function. pub(crate) fn check(input: &CheckInput) -> Result { // Reference in README file - if let Some(url) = readme_capture(&input.li.root, &[&OPENSSF_URL])? { + if let Some(url) = readme_capture(&input.li.root, &[&OPENSSF_URL, &OPENSSF_URL_LEGACY])? { return Ok(CheckOutput::passed().url(Some(url))); } @@ -40,7 +45,15 @@ mod tests { #[test] fn openssf_url_extract() { assert_eq!( - OPENSSF_URL.captures("[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4106/badge)](https://bestpractices.coreinfrastructure.org/projects/4106)").unwrap()[1].to_string(), + OPENSSF_URL.captures("[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/4106/badge)](https://www.bestpractices.dev/projects/4106)").unwrap()[1].to_string(), + "https://www.bestpractices.dev/projects/4106" + ); + } + + #[test] + fn openssf_url_legacy_extract() { + assert_eq!( + OPENSSF_URL_LEGACY.captures("[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/4106/badge)](https://bestpractices.coreinfrastructure.org/projects/4106)").unwrap()[1].to_string(), "https://bestpractices.coreinfrastructure.org/projects/4106" ); } diff --git a/docs/checks.md b/docs/checks.md index e1a7e1df..69affc57 100644 --- a/docs/checks.md +++ b/docs/checks.md @@ -495,6 +495,7 @@ This check passes if: - An `OpenSSF` best practices badge is found in the repository's `README` file. Regexps used: ```sh +"(https://www.bestpractices.dev/projects/\d+)" "(https://bestpractices.coreinfrastructure.org/projects/\d+)" ```