| 233 | 233 | | values.push(LISTED.into()); |
| 234 | 234 | | let rows = self |
| 235 | 235 | | .db |
| 236 | | − | .prepare(format!("SELECT {ADVISORY_COLUMNS} FROM advisories WHERE repo_id = ? AND state IN ({marks}) ORDER BY created_at DESC LIMIT ?")) |
| 236 | + | .prepare(format!("SELECT {ADVISORY_COLUMNS} FROM security_advisories WHERE repo_id = ? AND state IN ({marks}) ORDER BY created_at DESC LIMIT ?")) |
| 237 | 237 | | .bind(&values)? |
| 238 | 238 | | .all() |
| 239 | 239 | | .await? |
| ⋯ |
| 246 | 246 | | let column = if is_g1tsa_id(id) { "g1tsa_id" } else { "id" }; |
| 247 | 247 | | Ok(self |
| 248 | 248 | | .db |
| 249 | | − | .prepare(format!("SELECT {ADVISORY_COLUMNS} FROM advisories WHERE repo_id = ? AND {column} = ?")) |
| 249 | + | .prepare(format!("SELECT {ADVISORY_COLUMNS} FROM security_advisories WHERE repo_id = ? AND {column} = ?")) |
| 250 | 250 | | .bind(&[repo.repo_id.as_str().into(), id.into()])? |
| 251 | 251 | | .first::<AdvisoryRow>(None) |
| 252 | 252 | | .await? |
| ⋯ |
| 263 | 263 | | let at = rfc3339(now_ms); |
| 264 | 264 | | self.db |
| 265 | 265 | | .prepare( |
| 266 | | − | "INSERT INTO advisories (id, g1tsa_id, repo_id, title, description, severity, cvss_vector, cvss_score, cve_id, ecosystem, |
| 266 | + | "INSERT INTO security_advisories (id, g1tsa_id, repo_id, title, description, severity, cvss_vector, cvss_score, cve_id, ecosystem, |
| 267 | 267 | | package, affected_versions, patched_versions, state, credits, report_id, created_by, created_at, updated_at) |
| 268 | 268 | | VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'draft', ?, ?, ?, ?, ?)", |
| 269 | 269 | | ) |
| ⋯ |
| 295 | 295 | | pub async fn update_advisory(&self, repo: &RepoRow, id: &str, input: &AdvisoryInput) -> Result<()> { |
| 296 | 296 | | self.db |
| 297 | 297 | | .prepare( |
| 298 | | − | "UPDATE advisories SET title = ?, description = ?, severity = ?, cvss_vector = ?, cvss_score = ?, cve_id = ?, ecosystem = ?, |
| 298 | + | "UPDATE security_advisories SET title = ?, description = ?, severity = ?, cvss_vector = ?, cvss_score = ?, cve_id = ?, ecosystem = ?, |
| 299 | 299 | | package = ?, affected_versions = ?, patched_versions = ?, credits = ?, updated_at = ? |
| 300 | 300 | | WHERE repo_id = ? AND id = ?", |
| 301 | 301 | | ) |
| ⋯ |
| 328 | 328 | | _ => "published_at = published_at", |
| 329 | 329 | | }; |
| 330 | 330 | | self.db |
| 331 | | − | .prepare(format!("UPDATE advisories SET state = ?2, updated_at = ?1, {stamp} WHERE repo_id = ?3 AND id = ?4")) |
| 331 | + | .prepare(format!("UPDATE security_advisories SET state = ?2, updated_at = ?1, {stamp} WHERE repo_id = ?3 AND id = ?4")) |
| 332 | 332 | | .bind(&[at.as_str().into(), state.into(), repo.repo_id.as_str().into(), id.into()])? |
| 333 | 333 | | .run() |
| 334 | 334 | | .await?; |
| ⋯ |
| 443 | 443 | | pub async fn purge_advisories(&self, repo_id: &str) -> Result<()> { |
| 444 | 444 | | self.db |
| 445 | 445 | | .batch(vec![ |
| 446 | | − | self.db.prepare("DELETE FROM advisories WHERE repo_id = ?").bind(&[repo_id.into()])?, |
| 446 | + | self.db.prepare("DELETE FROM security_advisories WHERE repo_id = ?").bind(&[repo_id.into()])?, |
| 447 | 447 | | self.db.prepare("DELETE FROM vulnerability_reports WHERE repo_id = ?").bind(&[repo_id.into()])?, |
| 448 | 448 | | ]) |
| 449 | 449 | | .await?; |