Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: long version of go dependency unable to inserted into software table (CVE-2020-36569) #5221

Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/resources/data/initialize.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ CREATE ALIAS update_vulnerability FOR "org.owasp.dependencycheck.data.nvdcve.H2F
CREATE ALIAS insert_software FOR "org.owasp.dependencycheck.data.nvdcve.H2Functions.insertSoftware";

CREATE TABLE properties (id varchar(50) PRIMARY KEY, `value` varchar(500));
INSERT INTO properties(id, `value`) VALUES ('version', '5.2.1');
INSERT INTO properties(id, `value`) VALUES ('version', '5.2.2');
2 changes: 1 addition & 1 deletion core/src/main/resources/data/initialize_mssql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ END;

GO

INSERT INTO properties(id,value) VALUES ('version','5.2.1');
INSERT INTO properties(id,value) VALUES ('version','5.2.2');

GO
/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/data/initialize_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,4 @@ GRANT EXECUTE ON PROCEDURE dependencycheck.update_ecosystems2 TO 'dcuser';

GRANT SELECT, INSERT, UPDATE, DELETE ON dependencycheck.* TO 'dcuser';

INSERT INTO properties(id, value) VALUES ('version', '5.2.1');
INSERT INTO properties(id, value) VALUES ('version', '5.2.2');
2 changes: 1 addition & 1 deletion core/src/main/resources/data/initialize_oracle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,4 @@ CREATE OR REPLACE VIEW v_update_ecosystems AS
ON c.vendor=e.vendor
AND c.product=e.product;

INSERT INTO properties(id,value) VALUES ('version','5.2.1');
INSERT INTO properties(id,value) VALUES ('version','5.2.2');
2 changes: 1 addition & 1 deletion core/src/main/resources/data/initialize_postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,4 @@ GRANT EXECUTE ON FUNCTION public.insert_software (INT, CHAR(1), VARCHAR(255),



INSERT INTO properties(id,value) VALUES ('version','5.2.1');
INSERT INTO properties(id,value) VALUES ('version','5.2.2');
6 changes: 6 additions & 0 deletions core/src/main/resources/data/upgrade_5.3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALTER TABLE software ALTER COLUMN versionEndExcluding SET DATA TYPE VARCHAR(75);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest a higher number than 75, because it is the exact the size for this specific entry.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about 255 like other COLUMNs or even more. Is their a concret reason for 75 except that the current CVE needs 75?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am all for 255, at least I don't see a reason to not make it reasonably bigger, otherwise 75 is just us waiting for the next one to happen.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as @Keymaster65 already suggested, i would also prefer to take the column length of 255 chars:

Suggested change
ALTER TABLE software ALTER COLUMN versionEndExcluding SET DATA TYPE VARCHAR(75);
ALTER TABLE software ALTER COLUMN versionEndExcluding SET DATA TYPE VARCHAR(255);
ALTER TABLE software ALTER COLUMN versionEndIncluding SET DATA TYPE VARCHAR(255);
ALTER TABLE software ALTER COLUMN versionStartExcluding SET DATA TYPE VARCHAR(255);
ALTER TABLE software ALTER COLUMN versionStartIncluding SET DATA TYPE VARCHAR(255);

Copy link

@pijean-rca pijean-rca Jan 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not this file be named upgrade_5.2.1.sql ?

ALTER TABLE software ALTER COLUMN versionEndIncluding SET DATA TYPE VARCHAR(75);
ALTER TABLE software ALTER COLUMN versionStartExcluding SET DATA TYPE VARCHAR(75);
ALTER TABLE software ALTER COLUMN versionStartIncluding SET DATA TYPE VARCHAR(75);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ALTER TABLE software ALTER COLUMN versionEndExcluding SET DATA TYPE VARCHAR(75);
ALTER TABLE software ALTER COLUMN versionEndIncluding SET DATA TYPE VARCHAR(75);
ALTER TABLE software ALTER COLUMN versionStartExcluding SET DATA TYPE VARCHAR(75);
ALTER TABLE software ALTER COLUMN versionStartIncluding SET DATA TYPE VARCHAR(75);
ALTER TABLE software ALTER COLUMN versionEndExcluding SET DATA TYPE VARCHAR(100);
ALTER TABLE software ALTER COLUMN versionEndIncluding SET DATA TYPE VARCHAR(100);
ALTER TABLE software ALTER COLUMN versionStartExcluding SET DATA TYPE VARCHAR(100);
ALTER TABLE software ALTER COLUMN versionStartIncluding SET DATA TYPE VARCHAR(100);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say 255 is even more on the safe side, as @nusmanov suggested:

jeremylong marked this conversation as resolved.
Show resolved Hide resolved

UPDATE Properties SET `value`='5.2.2' WHERE ID='version';
2 changes: 1 addition & 1 deletion core/src/main/resources/dependencycheck.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ data.file_name=odc.mv.db
### if you increment the DB version then you must increment the database file path
### in the mojo.properties, task.properties (maven and ant respectively), and
### the gradle PurgeDataExtension.
data.version=5.2.1
Copy link

@pijean-rca pijean-rca Jan 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property is used to choose the update file (org.owasp.dependencycheck.data.nvdcve.DatabaseManager#DB_STRUCTURE_UPDATE_RESOURCE) when h2 is used (org.owasp.dependencycheck.data.nvdcve.DatabaseManager#updateSchema).

Analysis crashes when the upgrade file does not exist. Along with my previous comment I would say that this property should be equal to 5.2.1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not this property, but the database version property in your H2 database that governs which upgrade SQL is searched for. This property governs the expected database version (and if actual is lower than that will search for upgrade scripts to update the H2 database

data.version=5.2.2

#The analysis timeout in minutes
odc.analysis.timeout=180
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/resources/dependencycheck.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ engine.version.url=https://jeremylong.github.io/DependencyCheck/current.txt
data.directory=[JAR]/data/7.0
#if the filename has a %s it will be replaced with the current expected version
data.file_name=odc.mv.db
data.version=5.2.1
data.version=5.2.2

#The analysis timeout in minutes
odc.analysis.timeout=20
Expand Down
2 changes: 1 addition & 1 deletion utils/src/test/resources/dependencycheck.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ engine.version.url=https://jeremylong.github.io/DependencyCheck/current.txt
data.directory=[JAR]/data
#if the filename has a %s it will be replaced with the current expected version
data.file_name=0dc.mv.db
data.version=5.2.1
data.version=5.2.2

#The analysis timeout in minutes
odc.analysis.timeout=20
Expand Down