-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
53 changed files
with
5,084 additions
and
511 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
CREATE TABLE IF NOT EXISTS security_advisories ( | ||
advisory_id uuid primary key, | ||
hsec_id text not null, | ||
modified timestamptz not null, | ||
published timestamptz not null, | ||
capecs int[] not null, | ||
cwes int[] not null, | ||
keywords text[] not null, | ||
aliases text[] not null, | ||
related text[] not null, | ||
advisory_references jsonb not null, | ||
pandoc jsonb not null, | ||
html text not null, | ||
summary text not null, | ||
details text not null | ||
) | ||
advisory_id uuid PRIMARY KEY | ||
, hsec_id text NOT NULL | ||
, modified timestamptz NOT NULL | ||
, published timestamptz NOT NULL | ||
, capecs integer[] NOT NULL | ||
, cwes integer[] NOT NULL | ||
, keywords text[] NOT NULL | ||
, aliases text[] NOT NULL | ||
, related text[] NOT NULL | ||
, advisory_references text[] NOT NULL | ||
, pandoc jsonb NOT NULL | ||
, html text NOT NULL | ||
, summary text NOT NULL | ||
, details text NOT NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
CREATE TABLE IF NOT EXISTS affected_packages ( | ||
affected_package_id uuid primary key, | ||
advisory_id uuid references security_advisories, | ||
package_id uuid references packages not null, | ||
cvss text not null, | ||
introduced_version uuid references releases not null, | ||
fixed_version uuid references releases, | ||
architectures text[], | ||
operating_systems text[], | ||
declarations text[][] | ||
affected_package_id uuid PRIMARY KEY | ||
, advisory_id uuid REFERENCES security_advisories | ||
, package_id uuid REFERENCES packages NOT NULL | ||
, cvss text NOT NULL | ||
, architectures text[] | ||
, operating_systems text[] | ||
, declarations text[][] | ||
); | ||
|
||
CREATE INDEX affected_packages_advisory_id_fkey ON affected_packages(advisory_id); | ||
CREATE INDEX affected_packages_package_id_fkey ON affected_packages(package_id); | ||
CREATE INDEX affected_packages_introduced_version_fkey ON affected_packages(introduced_version); | ||
CREATE INDEX affected_packages_fixed_version_fkey ON affected_packages(fixed_version); | ||
CREATE INDEX affected_packages_advisory_id_fkey | ||
ON affected_packages (advisory_id); | ||
|
||
CREATE INDEX affected_packages_package_id_fkey | ||
ON affected_packages (package_id); |
12 changes: 12 additions & 0 deletions
12
migrations/20241014081932_create_affected_version_ranges.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CREATE TABLE IF NOT EXISTS affected_version_ranges ( | ||
affected_version_id uuid PRIMARY KEY | ||
, affected_package_id uuid REFERENCES affected_packages NOT NULL | ||
, introduced_version uuid REFERENCES releases (release_id) NOT NULL | ||
, fixed_version uuid REFERENCES releases (release_id) | ||
); | ||
|
||
CREATE INDEX affected_version_ranges_introduced_version_fkey | ||
ON affected_version_ranges (introduced_version); | ||
|
||
CREATE INDEX affected_version_ranges_fixed_version_fkey | ||
ON affected_version_ranges (fixed_version); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Flora.Model.Release.Guard where | ||
|
||
import Distribution.Types.Version (Version) | ||
import Effectful | ||
import Effectful.PostgreSQL.Transact.Effect | ||
import Effectful.Trace | ||
import Monitor.Tracing qualified as Tracing | ||
|
||
import Flora.Model.Package.Types | ||
import Flora.Model.Release.Query qualified as Query | ||
import Flora.Model.Release.Types | ||
|
||
guardThatReleaseExists | ||
:: (DB :> es, Trace :> es) | ||
=> PackageId | ||
-> Version | ||
-> (Version -> Eff es Release) | ||
-- ^ Action to run if the package does not exist | ||
-> Eff es Release | ||
guardThatReleaseExists packageId version action = do | ||
result <- | ||
Tracing.childSpan "Query.getReleaseByVersion" $ | ||
Query.getReleaseByVersion packageId version | ||
case result of | ||
Just release -> pure release | ||
Nothing -> action version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.