Skip to content

Add new columns to scan_result_policies table

What does this MR do and why?

Policy creators will be able to create separate policies that force approvals on previously detected vulnerabilities that may have been ignored.

Users can choose to require approvals if the age of the vulnerability is more than or less than the selected age (X Days, weeks, months, or years).

This MR adds the columns operator, interval, and value to scan_result_policies table to support age filtering for vulnerabilities.

This MR is part of issue #399116 (closed)

Migration up

main: == [advisory_lock_connection] object_id: 227920, pg_backend_pid: 66461
main: == 20230531164258 AddOperatorValueIntervalToScanResultPolicies: migrating =====
main: -- add_column(:scan_result_policies, :age_value, :integer)
main:    -> 0.0066s
main: -- add_column(:scan_result_policies, :age_operator, :integer, {:limit=>2})
main:    -> 0.0023s
main: -- add_column(:scan_result_policies, :age_interval, :integer, {:limit=>2})
main:    -> 0.0007s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- execute("ALTER TABLE scan_result_policies\nADD CONSTRAINT age_value_null_or_positive\nCHECK ( age_value IS NULL OR age_value >= 0 )\nNOT VALID;\n")
main:    -> 0.0013s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0003s
main: -- execute("ALTER TABLE scan_result_policies VALIDATE CONSTRAINT age_value_null_or_positive;")
main:    -> 0.0016s
main: -- execute("RESET statement_timeout")
main:    -> 0.0003s
main: == 20230531164258 AddOperatorValueIntervalToScanResultPolicies: migrated (0.2150s) 

Migration down

main: == [advisory_lock_connection] object_id: 227300, pg_backend_pid: 64778
main: == 20230531164258 AddOperatorValueIntervalToScanResultPolicies: reverting =====
main: -- remove_column(:scan_result_policies, :age_value)
main:    -> 0.0077s
main: -- remove_column(:scan_result_policies, :age_operator)
main:    -> 0.0008s
main: -- remove_column(:scan_result_policies, :age_interval)
main:    -> 0.0003s
main: == 20230531164258 AddOperatorValueIntervalToScanResultPolicies: reverted (0.0131s) 

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Marcos Rocha

Merge request reports

Loading