Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #70 from cisagov/AL-fix-PE_schema
Browse files Browse the repository at this point in the history
Fix syntax/naming errors in PE data schema
  • Loading branch information
cduhn17 committed Sep 30, 2021
2 parents c62ad98 + 0fa0463 commit 701dbb1
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/pe_reports/data/data_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ CREATE TABLE IF NOT EXISTS public.mentions
CREATE TABLE IF NOT EXISTS public.shodan_insecure_protocols_unverified_vulns
(
insecure_product_uid uuid default uuid_generate_v1() NOT NULL,
organization_uid uuid NOT NULL,
organizations_uid uuid NOT NULL,
organization text,
ip text,
port integer,
Expand All @@ -131,14 +131,15 @@ CREATE TABLE IF NOT EXISTS public.shodan_insecure_protocols_unverified_vulns
hostnames text[],
isn text,
asn integer,
UNIQUE (root_org, ip, port, protocol, timestamp),
UNIQUE (organizations_uid, ip, port, protocol, timestamp),
PRIMARY KEY (insecure_product_uid)
);

--Shodan Veriried Vulnerabilities table
CREATE TABLE IF NOT EXISTS public.shodan_verified_vulns
(
verified_vuln_uid uuid default uuid_generate_v1() NOT NULL,
organization_uid uuid NOT NULL,
organizations_uid uuid NOT NULL,
organization text,
ip text,
port text,
Expand All @@ -164,14 +165,15 @@ CREATE TABLE IF NOT EXISTS public.shodan_verified_vulns
hostnames text[],
isn text,
asn integer,
UNIQUE (root_org, ip, port, protocol, timestamp),
UNIQUE (organizations_uid, ip, port, protocol, timestamp),
PRIMARY KEY (verified_vuln_uid)
);

--Shodan Assets and IPs table
CREATE TABLE IF NOT EXISTS public.shodan_assets
(
shodan_asset_uid uuid default uuid_generate_v1() NOT NULL,
organization_uid uuid NOT NULL,
organizations_uid uuid NOT NULL,
organization text,
ip text,
port integer,
Expand All @@ -184,7 +186,7 @@ CREATE TABLE IF NOT EXISTS public.shodan_assets
hostnames text[],
isn text,
asn integer,
UNIQUE (root_org, ip, port, protocol, timestamp),
UNIQUE (organizations_uid, ip, port, protocol, timestamp),
PRIMARY KEY (shodan_asset_uid)
);

Expand All @@ -193,7 +195,7 @@ CREATE TABLE IF NOT EXISTS public.hibp_breaches
(
hibp_breaches_uid uuid default uuid_generate_v1() NOT NULL,
breach_id uuid NOT NULL,
breach_name text NOT NULL
breach_name text NOT NULL,
description text,
exposed_cred_count bigint,
breach_date date,
Expand Down Expand Up @@ -253,6 +255,7 @@ CREATE TABLE IF NOT EXISTS public.top_cves
PRIMARY KEY (top_cves_uid)
);


-- Table Relationships --
-- One to many relation between Organization and Domains
ALTER TABLE public.domains
Expand Down Expand Up @@ -326,14 +329,16 @@ ALTER TABLE public.alerts
REFERENCES public.organizations (organizations_uid)
NOT VALID;


-- One to Many Relationship for Mentions
-- Represented in complex SixGill "query": API.


-- Views --
-- HIBP complete breach view
Create View vw_breach_complete
AS
SELECT creds.hibp_exposed_credentials_uid,creds.email, creds.breach_name, creds.organization, creds.root_domain, creds.sub_domain,
SELECT creds.hibp_exposed_credentials_uid,creds.email, creds.breach_name, creds.organizations_uid, creds.root_domain, creds.sub_domain,
b.description, b.breach_date, b.added_date, b.modified_date, b.data_classes,
b.password_included, b.is_verified, b.is_fabricated, b.is_sensitive, b.is_retired, b.is_spam_list

Expand Down

0 comments on commit 701dbb1

Please sign in to comment.