@@ -69,8 +69,8 @@ var liveTableSpecs = func() []syncSpec {
6969 acInsertCols := []string {"id" , "purl" , "ecosystem" , "version" , "semver_introduced" , "semver_fixed" , "version_introduced" , "version_fixed" }
7070 acInsertExprs := []string {"id" , "purl" , "ecosystem" , "version" , "semver_introduced::semver" , "semver_fixed::semver" , "version_introduced" , "version_fixed" }
7171 pivotAllCols := []string {"affected_component_id" , "cve_id" }
72- exploitAllCols := []string {"id" , "published" , "updated" , "author" , "type" , "verified" , "source_url" , "description" , "cve_id" , "tags" , "forks" , "watchers" , "subscribers" , "stars" }
73- malPkgAllCols := []string {"id" , "summary" , "details" , "published" , "modified" }
72+ exploitAllCols := []string {"id" , "content_hash" , " published" , "updated" , "author" , "type" , "verified" , "source_url" , "description" , "cve_id" , "tags" , "forks" , "watchers" , "subscribers" , "stars" }
73+ malPkgAllCols := []string {"id" , "content_hash" , " summary" , "details" , "published" , "modified" }
7474 malCompInsertCols := []string {"id" , "malicious_package_id" , "purl" , "ecosystem" , "version" , "semver_introduced" , "semver_fixed" , "version_introduced" , "version_fixed" }
7575 malCompInsertExprs := []string {"id" , "malicious_package_id" , "purl" , "ecosystem" , "version::text" , "semver_introduced::semver" , "semver_fixed::semver" , "version_introduced" , "version_fixed" }
7676 return []syncSpec {
@@ -97,14 +97,14 @@ var liveTableSpecs = func() []syncSpec {
9797 },
9898 {
9999 live : "exploits" , stage : "exploits_stage" , keyCols : []string {"id" },
100- contentHashCol : "updated " ,
101- contentCols : []string {"published" , "updated" , "author" , "type" , "verified" , "source_url" , "description" , "cve_id" , "tags" , "forks" , "watchers" , "subscribers" , "stars" },
100+ contentHashCol : "content_hash " ,
101+ contentCols : []string {"content_hash" , " published" , "updated" , "author" , "type" , "verified" , "source_url" , "description" , "cve_id" , "tags" , "forks" , "watchers" , "subscribers" , "stars" },
102102 insertCols : exploitAllCols , insertSelectExprs : exploitAllCols ,
103103 },
104104 {
105105 live : "malicious_packages" , stage : "mal_pkgs_stage" , keyCols : []string {"id" },
106- contentHashCol : "modified " ,
107- contentCols : []string {"summary" , "details" , "published" , "modified" },
106+ contentHashCol : "content_hash " ,
107+ contentCols : []string {"content_hash" , " summary" , "details" , "published" , "modified" },
108108 insertCols : malPkgAllCols , insertSelectExprs : malPkgAllCols ,
109109 },
110110 {
@@ -730,13 +730,14 @@ func FlushOSVStagingTables(ctx context.Context, tx pgx.Tx) error {
730730
731731 t = time .Now ()
732732 if _ , err := tx .Exec (ctx , `
733- INSERT INTO malicious_packages (id, summary, details, published, modified)
734- SELECT id, summary, details, published, modified FROM mal_pkgs_stage
733+ INSERT INTO malicious_packages (id, content_hash, summary, details, published, modified)
734+ SELECT id, content_hash, summary, details, published, modified FROM mal_pkgs_stage
735735 ON CONFLICT (id) DO UPDATE SET
736- summary = EXCLUDED.summary,
737- details = EXCLUDED.details,
738- published = EXCLUDED.published,
739- modified = EXCLUDED.modified` ); err != nil {
736+ content_hash = EXCLUDED.content_hash,
737+ summary = EXCLUDED.summary,
738+ details = EXCLUDED.details,
739+ published = EXCLUDED.published,
740+ modified = EXCLUDED.modified` ); err != nil {
740741 return fmt .Errorf ("could not flush malicious_packages: %w" , err )
741742 }
742743 slog .Info ("flushed malicious_packages" , "took" , time .Since (t ))
@@ -768,19 +769,24 @@ func flushNonOSVStagingTables(ctx context.Context, tx pgx.Tx) error {
768769 return fmt .Errorf ("could not delete stale exploits: %w" , err )
769770 }
770771 if _ , err := tx .Exec (ctx , `
771- INSERT INTO exploits (id, published, updated, author, type, verified, source_url, description, cve_id, tags, forks, watchers, subscribers, stars)
772- SELECT id, published, updated, author, type, verified, source_url, description, cve_id, tags, forks, watchers, subscribers, stars
772+ INSERT INTO exploits (id, content_hash, published, updated, author, type, verified, source_url, description, cve_id, tags, forks, watchers, subscribers, stars)
773+ SELECT id, content_hash, published, updated, author, type, verified, source_url, description, cve_id, tags, forks, watchers, subscribers, stars
773774 FROM exploits_stage
774775 ON CONFLICT (id) DO UPDATE SET
775- published = EXCLUDED.published,
776- updated = EXCLUDED.updated,
777- author = EXCLUDED.author,
778- source_url = EXCLUDED.source_url,
779- description = EXCLUDED.description,
780- forks = EXCLUDED.forks,
781- watchers = EXCLUDED.watchers,
782- subscribers = EXCLUDED.subscribers,
783- stars = EXCLUDED.stars` ); err != nil {
776+ content_hash = EXCLUDED.content_hash,
777+ published = EXCLUDED.published,
778+ updated = EXCLUDED.updated,
779+ author = EXCLUDED.author,
780+ type = EXCLUDED.type,
781+ verified = EXCLUDED.verified,
782+ source_url = EXCLUDED.source_url,
783+ description = EXCLUDED.description,
784+ cve_id = EXCLUDED.cve_id,
785+ tags = EXCLUDED.tags,
786+ forks = EXCLUDED.forks,
787+ watchers = EXCLUDED.watchers,
788+ subscribers = EXCLUDED.subscribers,
789+ stars = EXCLUDED.stars` ); err != nil {
784790 return fmt .Errorf ("could not flush exploits: %w" , err )
785791 }
786792 slog .Info ("finished flushing non-osv staging tables (exploits)" , "total" , time .Since (t ))
@@ -830,28 +836,30 @@ func CreateStagingTables(ctx context.Context, tx pgx.Tx) error {
830836 ) ON COMMIT DROP;
831837
832838 CREATE TEMP TABLE IF NOT EXISTS exploits_stage (
833- id text,
834- published date,
835- updated date,
836- author text,
837- type text,
838- verified boolean,
839- source_url text,
840- description text,
841- cve_id text,
842- tags text,
843- forks integer,
844- watchers integer,
845- subscribers integer,
846- stars integer
839+ id text,
840+ content_hash bigint,
841+ published date,
842+ updated date,
843+ author text,
844+ type text,
845+ verified boolean,
846+ source_url text,
847+ description text,
848+ cve_id text,
849+ tags text,
850+ forks integer,
851+ watchers integer,
852+ subscribers integer,
853+ stars integer
847854 ) ON COMMIT DROP;
848855
849856 CREATE TEMP TABLE IF NOT EXISTS mal_pkgs_stage (
850- id text,
851- summary text,
852- details text,
853- published timestamptz,
854- modified timestamptz
857+ id text,
858+ content_hash bigint,
859+ summary text,
860+ details text,
861+ published timestamptz,
862+ modified timestamptz
855863 ) ON COMMIT DROP;
856864
857865 CREATE TEMP TABLE IF NOT EXISTS mal_comps_stage (
0 commit comments