Skip to content

Commit

Permalink
Merge branch 'master' into cve-info-doc-update
Browse files Browse the repository at this point in the history
  • Loading branch information
timopollmeier authored Nov 17, 2020
2 parents b206ad9 + afa0e4b commit 2c46c45
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
- Parameter `--db-user` to set a database user [#1327](https://github.com/greenbone/gvmd/pull/1327)
- Add `allow_simult_ips_same_host` field for targets [#1346](https://github.com/greenbone/gvmd/pull/1346)
- Speed up GET_VULNS [#1354](https://github.com/greenbone/gvmd/pull/1354)
- Speed up GET_VULNS [#1354](https://github.com/greenbone/gvmd/pull/1354) [#1355](https://github.com/greenbone/gvmd/pull/1354)

### Changed
- Move EXE credential generation to a Python script [#1260](https://github.com/greenbone/gvmd/pull/1260) [#1262](https://github.com/greenbone/gvmd/pull/1262)
Expand Down
22 changes: 10 additions & 12 deletions src/manage_pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,14 +1646,6 @@ manage_create_result_indexes ()
sql ("SELECT create_index ('results_by_date', 'results', 'date');");
}

/**
* @brief Results WHERE SQL for creating views in create_tabes.
*/
#define VULNS_RESULTS_WHERE \
" WHERE uuid IN" \
" (SELECT nvt FROM results" \
" WHERE (results.severity != " G_STRINGIFY (SEVERITY_ERROR) "))"

/**
* @brief Create or replace the vulns view.
*/
Expand All @@ -1667,30 +1659,36 @@ create_view_vulns ()
" ::integer;",
sql_database ()))
sql ("CREATE OR REPLACE VIEW vulns AS"
" WITH used_nvts"
" AS (SELECT DISTINCT nvt FROM results"
" WHERE (results.severity != " G_STRINGIFY (SEVERITY_ERROR) "))"
" SELECT id, uuid, name, creation_time, modification_time,"
" cast (cvss_base AS double precision) AS severity, qod,"
" 'nvt' AS type"
" FROM nvts"
VULNS_RESULTS_WHERE
" WHERE uuid in (SELECT * FROM used_nvts)"
" UNION SELECT id, uuid, name, creation_time, modification_time,"
" score / 10.0 AS severity, "
G_STRINGIFY (QOD_DEFAULT) " AS qod,"
" 'cve' AS type"
" FROM cves"
VULNS_RESULTS_WHERE
" WHERE uuid in (SELECT * FROM used_nvts)"
" UNION SELECT id, uuid, name, creation_time, modification_time,"
" score / 10.0 AS severity, "
G_STRINGIFY (QOD_DEFAULT) " AS qod,"
" 'ovaldef' AS type"
" FROM ovaldefs"
VULNS_RESULTS_WHERE);
" WHERE uuid in (SELECT * FROM used_nvts)");
else
sql ("CREATE OR REPLACE VIEW vulns AS"
" WITH used_nvts"
" AS (SELECT DISTINCT nvt FROM results"
" WHERE (results.severity != " G_STRINGIFY (SEVERITY_ERROR) "))"
" SELECT id, uuid, name, creation_time, modification_time,"
" cast (cvss_base AS double precision) AS severity, qod,"
" 'nvt' AS type"
" FROM nvts"
VULNS_RESULTS_WHERE);
" WHERE uuid in (SELECT * FROM used_nvts)");
}

#undef VULNS_RESULTS_WHERE
Expand Down

0 comments on commit 2c46c45

Please sign in to comment.