Skip to content

Commit

Permalink
boulder/draft: Auto guess rss for pypi URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
joebonrichie committed Jan 11, 2025
1 parent 04ad263 commit 1fa2bc7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions boulder/src/draft/monitoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<'a> Monitoring<'a> {

let id = self.find_monitoring_id(self.name, &client)?;
let cpes = self.find_security_cpe(self.name, &client)?;
let rss = self.guess_rss(self.homepage);
let rss = self.guess_rss(self.homepage, self.name);

let output = self.format_monitoring(id, cpes, rss)?;

Expand Down Expand Up @@ -164,9 +164,15 @@ impl<'a> Monitoring<'a> {
Ok(cpes)
}

fn guess_rss(&self, homepage: &String) -> Option<String> {
fn guess_rss(&self, homepage: &String, name: &String) -> Option<String> {
match homepage {
_ if homepage.starts_with("https://github.com") => Some(format!("{homepage}/releases.atom")),
_ if homepage.starts_with("https://files.pythonhosted.org")
|| homepage.starts_with("https://pypi.org")
|| homepage.starts_with("https://pypi.io") =>
{
Some(format!("https://pypi.org/rss/project/{name}/releases.xml"))
}
_ => None,
}
}
Expand Down

0 comments on commit 1fa2bc7

Please sign in to comment.