Skip to content

make "qualifiers" not null in "vulnerabilities_package" #311

Description

@sify21

Currently vulnerabilities_package is defined as

                                      Table "public.vulnerabilities_package"
   Column   |          Type          | Collation | Nullable |                       Default                       
------------+------------------------+-----------+----------+-----------------------------------------------------
 id         | integer                |           | not null | nextval('vulnerabilities_package_id_seq'::regclass)
 type       | character varying(16)  |           | not null | 
 namespace  | character varying(255) |           | not null | 
 name       | character varying(100) |           | not null | 
 version    | character varying(100) |           | not null | 
 subpath    | character varying(200) |           | not null | 
 qualifiers | jsonb                  |           |          | 
Indexes:
    "vulnerabilities_package_pkey" PRIMARY KEY, btree (id)
    "vulnerabilities_package_name_namespace_type_vers_4f1568e6_uniq" UNIQUE CONSTRAINT, btree (name, namespace, type, version, qualifiers, subpath)
Referenced by:
    TABLE "vulnerabilities_packagerelatedvulnerability" CONSTRAINT "vulnerabilities_pack_package_id_65b7b522_fk_vulnerabi" FOREIGN KEY (package_id) REFERENCES vulnerabilities_package(id) DEFERRABLE INITIALLY DEFERRED

qualifiers can be null, so the unique constraint vulnerabilities_package_name_namespace_type_vers_4f1568e6_uniq doesn't stop from inserting multiple rows with qualifiers being null and the other columns being identical, which allows duplicate packages in this table. See PostgreSQL multi-column unique constraint and NULL values for reference.

Another possible solution is to make qualifiers not null, and use '{}'::jsonb as empty value.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions