Allow multiple threat types in the Spec11ThreatMatch table (#650)

* Update to generic Spec11ThreatMatch table

* Fix SQL syntax

* Make changes to the schema and add a test for null and empty threatTypes

* Fix a small typo

* Change the exception thrown with illegal arguments

Change the import for isNullOrEmpty

* Fix import for checkArgument

* Added a threat to test multiple threat types
This commit is contained in:
Legina Chen 2020-06-26 10:35:00 -07:00 committed by GitHub
parent 74b2de5c35
commit 5c5b6b20ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 129 additions and 56 deletions

View file

@ -657,16 +657,16 @@ ALTER SEQUENCE public."ReservedList_revision_id_seq" OWNED BY public."ReservedLi
--
-- Name: SafeBrowsingThreat; Type: TABLE; Schema: public; Owner: -
-- Name: Spec11ThreatMatch; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public."SafeBrowsingThreat" (
CREATE TABLE public."Spec11ThreatMatch" (
id bigint NOT NULL,
check_date text NOT NULL,
domain_name text NOT NULL,
domain_repo_id text NOT NULL,
registrar_id text NOT NULL,
threat_type text NOT NULL,
threat_types text[] NOT NULL,
tld text NOT NULL
);
@ -687,7 +687,7 @@ CREATE SEQUENCE public."SafeBrowsingThreat_id_seq"
-- Name: SafeBrowsingThreat_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public."SafeBrowsingThreat_id_seq" OWNED BY public."SafeBrowsingThreat".id;
ALTER SEQUENCE public."SafeBrowsingThreat_id_seq" OWNED BY public."Spec11ThreatMatch".id;
--
@ -747,10 +747,10 @@ ALTER TABLE ONLY public."ReservedList" ALTER COLUMN revision_id SET DEFAULT next
--
-- Name: SafeBrowsingThreat id; Type: DEFAULT; Schema: public; Owner: -
-- Name: Spec11ThreatMatch id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."SafeBrowsingThreat" ALTER COLUMN id SET DEFAULT nextval('public."SafeBrowsingThreat_id_seq"'::regclass);
ALTER TABLE ONLY public."Spec11ThreatMatch" ALTER COLUMN id SET DEFAULT nextval('public."SafeBrowsingThreat_id_seq"'::regclass);
--
@ -906,10 +906,10 @@ ALTER TABLE ONLY public."ReservedList"
--
-- Name: SafeBrowsingThreat SafeBrowsingThreat_pkey; Type: CONSTRAINT; Schema: public; Owner: -
-- Name: Spec11ThreatMatch SafeBrowsingThreat_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."SafeBrowsingThreat"
ALTER TABLE ONLY public."Spec11ThreatMatch"
ADD CONSTRAINT "SafeBrowsingThreat_pkey" PRIMARY KEY (id);
@ -1175,24 +1175,24 @@ CREATE INDEX reservedlist_name_idx ON public."ReservedList" USING btree (name);
--
-- Name: safebrowsing_threat_check_date_idx; Type: INDEX; Schema: public; Owner: -
-- Name: spec11threatmatch_check_date_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX safebrowsing_threat_check_date_idx ON public."SafeBrowsingThreat" USING btree (check_date);
CREATE INDEX spec11threatmatch_check_date_idx ON public."Spec11ThreatMatch" USING btree (check_date);
--
-- Name: safebrowsing_threat_registrar_id_idx; Type: INDEX; Schema: public; Owner: -
-- Name: spec11threatmatch_registrar_id_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX safebrowsing_threat_registrar_id_idx ON public."SafeBrowsingThreat" USING btree (registrar_id);
CREATE INDEX spec11threatmatch_registrar_id_idx ON public."Spec11ThreatMatch" USING btree (registrar_id);
--
-- Name: safebrowsing_threat_tld_idx; Type: INDEX; Schema: public; Owner: -
-- Name: spec11threatmatch_tld_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX safebrowsing_threat_tld_idx ON public."SafeBrowsingThreat" USING btree (tld);
CREATE INDEX spec11threatmatch_tld_idx ON public."Spec11ThreatMatch" USING btree (tld);
--
@ -1460,18 +1460,18 @@ ALTER TABLE ONLY public."PollMessage"
--
-- Name: SafeBrowsingThreat fk_safebrowsing_threat_domain_repo_id; Type: FK CONSTRAINT; Schema: public; Owner: -
-- Name: Spec11ThreatMatch fk_safebrowsing_threat_domain_repo_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."SafeBrowsingThreat"
ALTER TABLE ONLY public."Spec11ThreatMatch"
ADD CONSTRAINT fk_safebrowsing_threat_domain_repo_id FOREIGN KEY (domain_repo_id) REFERENCES public."Domain"(repo_id);
--
-- Name: SafeBrowsingThreat fk_safebrowsing_threat_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
-- Name: Spec11ThreatMatch fk_safebrowsing_threat_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."SafeBrowsingThreat"
ALTER TABLE ONLY public."Spec11ThreatMatch"
ADD CONSTRAINT fk_safebrowsing_threat_registrar_id FOREIGN KEY (registrar_id) REFERENCES public."Registrar"(registrar_id);