Load advisory-db from local repo

This commit is contained in:
Folyd 2023-03-22 22:15:38 +08:00
parent 8ad10ec40e
commit 3b9796a8a3
3 changed files with 9 additions and 6 deletions

View file

@ -20,5 +20,6 @@ jobs:
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
git clone --depth 1 https://github.com/jplatte/caniuse.rs.git /tmp/caniuse
git clone --depth 1 https://github.com/nrc/rfc-index.git /tmp/rfcs
git clone --depth 1 https://github.com/rustsec/advisory-db.git /tmp/advisory-db
- name: Deloy docs
run: ./scripts/deploy-docs.sh

View file

@ -1,9 +1,7 @@
use std::{collections::HashMap, io::Write, path::Path};
use argh::FromArgs;
use rustsec::{
database::Query, repository::git::DEFAULT_URL, Advisory, Collection, Database, Repository,
};
use rustsec::{database::Query, Advisory, Collection, Database, Repository};
use super::Task;
@ -12,12 +10,16 @@ const ADVISORY_INDEX_PATH: &str = "../docs/static/advisory";
/// Advisory task
#[derive(FromArgs)]
#[argh(subcommand, name = "advisory")]
pub struct AdvisoryTask {}
pub struct AdvisoryTask {
/// advisory-db repository path
#[argh(option, short = 'r')]
repo_path: String,
}
impl Task for AdvisoryTask {
fn execute(&self) -> crate::Result<()> {
let mut map = HashMap::new();
let repo = Repository::fetch(DEFAULT_URL, "/tmp/advisory-db", true)?;
let repo = Repository::open(&self.repo_path)?;
let db = Database::load_from_repo(&repo)?;
for advisory in db
.query(&Query::new().collection(Collection::Crates).withdrawn(false))

View file

@ -14,7 +14,7 @@ RUST_BACKTRACE=full cargo run --target-dir /tmp --manifest-path=rust/Cargo.toml
RUST_BACKTRACE=full cargo run --target-dir /tmp --manifest-path=rust/Cargo.toml targets -d /tmp/public/index/targets.js
RUST_BACKTRACE=full cargo run --target-dir /tmp --manifest-path=rust/Cargo.toml caniuse -r /tmp/caniuse -d /tmp/public/index/caniuse.js
RUST_BACKTRACE=full cargo run --target-dir /tmp --manifest-path=rust/Cargo.toml rfcs -r /tmp/rfcs -d /tmp/public/index/rfcs.js
RUST_BACKTRACE=full cargo run --target-dir /tmp --manifest-path=rust/Cargo.toml advisory
RUST_BACKTRACE=full cargo run --target-dir /tmp --manifest-path=rust/Cargo.toml advisory -r /tmp/advisory-db
# Copy commands.js
cp extension/index/commands.js /tmp/public/index/commands.js