Skip to content

Commit

Permalink
Add per-project has_cves flag (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed May 14, 2020
1 parent 1170654 commit 5924e69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions sql.d/update/create_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ CREATE TABLE metapackages (
num_repos_newest smallint NOT NULL DEFAULT 0,
num_families_newest smallint NOT NULL DEFAULT 0,
has_related boolean NOT NULL DEFAULT false,
has_cves boolean NOT NULL DEFAULT false,

first_seen timestamp with time zone NOT NULL DEFAULT now(),
orphaned_at timestamp with time zone
Expand Down
6 changes: 5 additions & 1 deletion sql.d/update/update_projects.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ SET
num_repos_newest = tmp.num_repos_newest,
num_families_newest = tmp.num_families_newest,

has_cves = tmp.has_cves,

orphaned_at = NULL
FROM (
SELECT
Expand All @@ -43,7 +45,8 @@ FROM (
count(DISTINCT repo) FILTER (WHERE NOT shadow) AS num_repos_nonshadow,
count(DISTINCT family) AS num_families,
count(DISTINCT repo) FILTER (WHERE versionclass = 1 OR versionclass = 5) AS num_repos_newest,
count(DISTINCT family) FILTER (WHERE versionclass = 1 OR versionclass = 5) AS num_families_newest
count(DISTINCT family) FILTER (WHERE versionclass = 1 OR versionclass = 5) AS num_families_newest,
EXISTS(SELECT * FROM all_cpes INNER JOIN vulnerable_versions USING(cpe_vendor, cpe_product) WHERE all_cpes.effname = incoming_packages.effname) AS has_cves
FROM incoming_packages
GROUP BY effname
) AS tmp
Expand All @@ -59,6 +62,7 @@ SET
num_families_newest = 0,

has_related = false,
has_cves = false,

orphaned_at = now()
FROM (SELECT DISTINCT effname FROM incoming_packages) alive_projects RIGHT OUTER JOIN changed_projects USING(effname)
Expand Down

0 comments on commit 5924e69

Please sign in to comment.