Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cn-kali-team committed Dec 19, 2024
1 parent 88a5b62 commit ae4c7b6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions helper/tests/tests_cvss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ mod tests {
("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:H/A:H", 9.4),
("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H", 10.0),
("CVSS:3.1/AV:A/AC:H/PR:H/UI:R/S:U/C:N/I:N/A:L", 1.8),
("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:N", 0.0),
]);
for (c, s) in cvss_map.into_iter() {
let cvss_v3 = nvd_cvss::v3::CVSS::from_str(c).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions nvd-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ chrono = { version = "0.4", default-features = false, features = ["serde"] }
thiserror = "2.0"
uuid = { version = "1.6.1", features = ["v4", "serde", "v7"] }
serde_json = { version = "1", features = ["preserve_order"] }
utoipa = { version = "5.2.0", features = ["actix_extras", "chrono", "uuid", "openapi_extensions"], optional = true }
utoipa-swagger-ui = { version = "8.0.3", features = ["actix-web"], optional = true }
utoipa = { version = "4.2.0", features = ["actix_extras", "chrono", "uuid", "openapi_extensions"], optional = true }
utoipa-swagger-ui = { version = "6.0.0", features = ["actix-web"], optional = true }
yew = { version = "0.21.0", features = ["csr"], optional = true }
nvd-cves = { version = "0.1.1" }
[features]
Expand Down
4 changes: 2 additions & 2 deletions nvd-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ actix-cors = "0.7.0"
mysqlclient-sys = "0.4.0"
thiserror = "2.0"
env_logger = "0.11.1"
utoipa = { version = "5.2.0", features = ["actix_extras", "chrono", "uuid", "openapi_extensions"], optional = true }
utoipa-swagger-ui = { version = "8.0.3", features = ["actix-web"], optional = true }
utoipa = { version = "4.2.0", features = ["actix_extras", "chrono", "uuid", "openapi_extensions"], optional = true }
utoipa-swagger-ui = { version = "6.0.0", features = ["actix-web"], optional = true }
nvd-model = { path = "../nvd-model", version = "0.0.0", features = ["db", "openapi"] }
[features]
openapi = ["utoipa", "utoipa-swagger-ui"]
Expand Down
13 changes: 7 additions & 6 deletions nvd-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ use utoipa_swagger_ui::SwaggerUi;
async fn main() -> std::io::Result<()> {
let connection_pool = init_db_pool();
env_logger::init_from_env(env_logger::Env::new().default_filter_or("debug"));
#[cfg(feature = "openapi")]
let openapi = ApiDoc::openapi();
HttpServer::new(move || {
let cors = Cors::default()
.allowed_origin_fn(|origin, _req_head| origin.as_bytes().ends_with(b".kali-team.cn"))
Expand All @@ -28,7 +26,7 @@ async fn main() -> std::io::Result<()> {
let session = SessionMiddleware::builder(CookieSessionStore::default(), secret_key)
.cookie_http_only(false)
.build();
let app = App::new()
let mut app = App::new()
.wrap(cors)
.wrap(middleware::Logger::default())
.wrap(session)
Expand All @@ -41,9 +39,12 @@ async fn main() -> std::io::Result<()> {
)
.service(sitemap);
#[cfg(feature = "openapi")]
let app = app
.service(SwaggerUi::new("/swagger-ui/{_:.*}").url("/api-docs/openapi.json", openapi.clone()));

{
let openapi = ApiDoc::openapi();
app = app.service(
SwaggerUi::new("/swagger-ui/{_:.*}").url("/api-docs/openapi.json", openapi.clone()),
);
}
app.service(
actix_files::Files::new("/", "dist")
.prefer_utf8(true)
Expand Down

0 comments on commit ae4c7b6

Please sign in to comment.