-
-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**STOP**: Is this a **security vulnerability**? If so, follow Responsible Disclosure and email us at [email protected] instead of opening a public PR. Co-authored-by: Free Wortley <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
89feac9
commit d38dae8
Showing
13 changed files
with
434 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ node_modules | |
docker-compose.*.yaml | ||
.env.docker | ||
outputs/ | ||
out/ | ||
.log* | ||
|
||
.yarn/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...ce/bsl/hasura/metadata/databases/lunatrace/tables/vulnerability_cisa_known_exploited.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
table: | ||
name: cisa_known_exploited | ||
schema: vulnerability | ||
computed_fields: | ||
- name: vulnerability | ||
definition: | ||
function: | ||
name: cisa_known_exploited_vulnerability | ||
schema: vulnerability | ||
table_argument: known_exploited | ||
comment: Vulnerability referenced by the known exploited vulnerability. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...sura/migrations/lunatrace/1672788403469_add_cisa_known_exploited_vulnerabilities/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
DROP TABLE IF EXISTS vulnerability.cisa_known_exploited CASCADE; | ||
DROP INDEX IF EXISTS vulnerability_equivalent_b_idx; | ||
DROP FUNCTION vulnerability.cisa_known_exploited_vulnerability; | ||
DROP FUNCTION vulnerability.vulnerability_cisa_known_exploited; |
37 changes: 37 additions & 0 deletions
37
...hasura/migrations/lunatrace/1672788403469_add_cisa_known_exploited_vulnerabilities/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
-- Indexes to speed up EPSS inserter | ||
CREATE INDEX IF NOT EXISTS vulnerability_equivalent_b_idx ON vulnerability.equivalent (b); | ||
|
||
CREATE INDEX IF NOT EXISTS vulnerability_vulnerability_source_id_idx ON vulnerability.vulnerability (source_id); | ||
|
||
-- Table to hold the CISA Known Exploited vulnerabilities | ||
CREATE TABLE IF NOT EXISTS vulnerability.cisa_known_exploited ( | ||
"id" uuid NOT NULL DEFAULT gen_random_uuid(), | ||
cve TEXT UNIQUE, | ||
vendor_project text NOT NULL, | ||
product text NOT NULL, | ||
vulnerability_name text NOT NULL, | ||
date_added date NOT NULL, | ||
short_description text NOT NULL, | ||
required_action text NOT NULL, | ||
due_date date NOT NULL, | ||
notes text NOT NULL, | ||
PRIMARY KEY ("id"), | ||
CHECK (cve LIKE 'CVE-%') | ||
); | ||
|
||
CREATE OR REPLACE FUNCTION vulnerability.cisa_known_exploited_vulnerability(known_exploited vulnerability.cisa_known_exploited) | ||
RETURNS SETOF vulnerability.vulnerability AS $$ | ||
SELECT * | ||
FROM vulnerability.vulnerability | ||
WHERE source_id = known_exploited.cve | ||
$$ LANGUAGE sql STABLE; | ||
|
||
CREATE OR REPLACE FUNCTION vulnerability.vulnerability_cisa_known_exploited(vulnerability vulnerability.vulnerability) | ||
RETURNS SETOF vulnerability.cisa_known_exploited | ||
LANGUAGE sql | ||
STABLE | ||
AS $function$ | ||
SELECT * | ||
FROM vulnerability.cisa_known_exploited | ||
WHERE cve = vulnerability.source_id | ||
$function$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
bin/ | ||
.lunatrace.yaml | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright by LunaSec (owned by Refinery Labs, Inc) | ||
// | ||
// Licensed under the Business Source License v1.1 | ||
// (the "License"); you may not use this file except in compliance with the | ||
// License. You may obtain a copy of the License at | ||
// | ||
// https://github.com/lunasec-io/lunasec/blob/master/licenses/BSL-LunaTrace.txt | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package cisa | ||
|
||
import ( | ||
"github.com/ajvpot/clifx" | ||
"github.com/lunasec-io/lunasec/lunatrace/bsl/ingest-worker/pkg/cisa" | ||
"github.com/rs/zerolog/log" | ||
"github.com/urfave/cli/v2" | ||
"go.uber.org/fx" | ||
) | ||
|
||
type Params struct { | ||
fx.In | ||
|
||
Ingester cisa.CISAKnownVulnIngester | ||
} | ||
|
||
func NewCommand(p Params) clifx.CommandResult { | ||
return clifx.CommandResult{ | ||
Command: &cli.Command{ | ||
Name: "cisa", | ||
Subcommands: []*cli.Command{ | ||
{ | ||
Name: "ingest", | ||
Usage: "[file or directory]", | ||
Flags: []cli.Flag{}, | ||
Subcommands: []*cli.Command{}, | ||
Action: func(ctx *cli.Context) error { | ||
log.Info(). | ||
Msg("Updating CISA Known Vulnerabilities") | ||
err := p.Ingester.Ingest(ctx.Context) | ||
if err == nil { | ||
log.Info(). | ||
Msg("Updated CISA Known Vulnerabilities") | ||
} | ||
return err | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.