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 #36 from cisagov/AL-dataSchema
Browse files Browse the repository at this point in the history
Created data_schema.sql and added dns masquerading table
  • Loading branch information
schmelz21 committed Aug 27, 2021
2 parents 58444b5 + 5983cf3 commit df181d8
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions src/pe_reports/data/data_schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
--
-- PostgreSQL database dump
--

-- Draft Database Schema to store scan data
-- Includes Domain Masquerading, Credentals Exposed, Inffered Vulns, and Dark Web data

BEGIN;

-- Organizations table
CREATE TABLE IF NOT EXISTS public.organizations
(
organization_id text NOT NULL,
name text NOT NULL,
root_domains text[],
PRIMARY KEY (organization_id)
);

-- Domains table
CREATE TABLE IF NOT EXISTS public.domains
(
domain_id text NOT NULL,
organization_id text NOT NULL,
root_domain text NOT NULL,
ip_address text,
PRIMARY KEY (domain_id)
);

-- Domain Masquerading Table
CREATE TABLE IF NOT EXISTS public."DNSTwist"
(
id text NOT NULL,
"discoveredBy" text NOT NULL,
"domain-name" text,
"dns-a" text,
"dns-aaaa" text,
"dns-mx" text,
"dns-ns" text,
fuzzer text,
"date-observed" text,
"ssdeep-score" text,
organization_id text NOT NULL,
PRIMARY KEY (id)
);

-- One to many relation between Organization and Domains
ALTER TABLE public.organizations
ADD FOREIGN KEY (organization_id)
REFERENCES public.domains (organization_id)
NOT VALID;

-- One to many relation between Organization and DNSTwist results
ALTER TABLE public.organizations
ADD FOREIGN KEY (organization_id)
REFERENCES public."DNSTwist" (organization_id)
NOT VALID;

-- One to many relation between Domains and DNSTwist results
ALTER TABLE public.domains
ADD FOREIGN KEY (domain_id)
REFERENCES public."DNSTwist" ("discoveredBy")
NOT VALID;

END;

0 comments on commit df181d8

Please sign in to comment.