-
Jamie Tanna authored
As noted in #470, the anonymisation feature may have been useful, but has not been used. Although we could keep the feature in, it is regularly _not_ being implemented when new repositories are being created, so a user expecting the feature to be available will be lulled into a false sense of security. Instead, we should remove the feature. In `repositorymetadata` we need to still retain a single query, as `sqlc` requires at least one query per schema. Closes #470, #471, #306, #283, #274, #221, #165.
Jamie Tanna authoredAs noted in #470, the anonymisation feature may have been useful, but has not been used. Although we could keep the feature in, it is regularly _not_ being implemented when new repositories are being created, so a user expecting the feature to be available will be lulled into a false sense of security. Instead, we should remove the feature. In `repositorymetadata` we need to still retain a single query, as `sqlc` requires at least one query per schema. Closes #470, #471, #306, #283, #274, #221, #165.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
queries.sql.go 5.08 KiB
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.23.0
// source: queries.sql
package db
import (
"context"
"database/sql"
)
const insertProductCycle = `-- name: InsertProductCycle :exec
insert into endoflifedate_products (
product_name,
cycle,
supported_until,
eol_from,
inserted_at
) VALUES (
?,
?,
?,
?,
?
)
`
type InsertProductCycleParams struct {
ProductName string
Cycle string
SupportedUntil sql.NullString
EolFrom sql.NullString
InsertedAt string
}
func (q *Queries) InsertProductCycle(ctx context.Context, arg InsertProductCycleParams) error {
_, err := q.db.ExecContext(ctx, insertProductCycle,
arg.ProductName,
arg.Cycle,
arg.SupportedUntil,
arg.EolFrom,
arg.InsertedAt,
)
return err
}
const insertRenovateEndOfLife = `-- name: InsertRenovateEndOfLife :exec
insert into renovate_endoflife (
package_name,
version,
current_version,
package_manager,
datasource,
product_name,
cycle
) VALUES (
?,
?,
?,
?,
?,
?,
?
)
`
type InsertRenovateEndOfLifeParams struct {
PackageName string
Version string
CurrentVersion sql.NullString
PackageManager string
Datasource string
ProductName string
Cycle string
}
func (q *Queries) InsertRenovateEndOfLife(ctx context.Context, arg InsertRenovateEndOfLifeParams) error {
_, err := q.db.ExecContext(ctx, insertRenovateEndOfLife,
arg.PackageName,
arg.Version,
arg.CurrentVersion,
arg.PackageManager,
arg.Datasource,
arg.ProductName,
arg.Cycle,
)
return err
}
const insertSBOMEndOfLife = `-- name: InsertSBOMEndOfLife :exec
insert into sboms_endoflife (
package_name,
version,
current_version,
package_type,
product_name,
cycle
) VALUES (
?,
?,
?,
?,
?,
?
)
`
type InsertSBOMEndOfLifeParams struct {
PackageName string
Version sql.NullString
CurrentVersion sql.NullString
PackageType string
ProductName string
Cycle string
}
func (q *Queries) InsertSBOMEndOfLife(ctx context.Context, arg InsertSBOMEndOfLifeParams) error {
_, err := q.db.ExecContext(ctx, insertSBOMEndOfLife,
arg.PackageName,
arg.Version,
arg.CurrentVersion,
arg.PackageType,
arg.ProductName,
arg.Cycle,
)
return err
}
const retrieveDistinctRenovateDeps = `-- name: RetrieveDistinctRenovateDeps :many
select
distinct package_name,
version,
current_version,
renovate.package_manager,
datasource
from
renovate
left join sensitive_packages as sp on
renovate.package_name like replace(sp.package_pattern, '*', '%')
where
(
case
when sp.package_manager IS NOT NULL then sp.package_manager == renovate.package_manager
else true
end
)
and (
case
when sp.match_strategy = 'MATCHES' then false
when sp.match_strategy = 'DOES_NOT_MATCH' then true
else true
end
)
`
type RetrieveDistinctRenovateDepsRow struct {
PackageName string
Version string
CurrentVersion sql.NullString
PackageManager string
Datasource string
}
// ---------- Renovate
func (q *Queries) RetrieveDistinctRenovateDeps(ctx context.Context) ([]RetrieveDistinctRenovateDepsRow, error) {
rows, err := q.db.QueryContext(ctx, retrieveDistinctRenovateDeps)
if err != nil {
return nil, err
}
defer rows.Close()
var items []RetrieveDistinctRenovateDepsRow
for rows.Next() {
var i RetrieveDistinctRenovateDepsRow
if err := rows.Scan(
&i.PackageName,
&i.Version,
&i.CurrentVersion,
&i.PackageManager,
&i.Datasource,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const retrieveDistinctSBOMDeps = `-- name: RetrieveDistinctSBOMDeps :many
select
distinct package_name,
version,
current_version,
sboms.package_type
from
sboms
left join sensitive_packages as sp on
sboms.package_name like replace(sp.package_pattern, '*', '%')
where
(
version is not null
or
current_version is not null
)
and
(
case
when sp.package_manager IS NOT NULL then sp.package_manager == sboms.package_type
else true
end
)
and (
case
when sp.match_strategy = 'MATCHES' then false
when sp.match_strategy = 'DOES_NOT_MATCH' then true
else true
end
)
`
type RetrieveDistinctSBOMDepsRow struct {
PackageName string
Version sql.NullString
CurrentVersion sql.NullString
PackageType string
}
// ---------- SBOMs
func (q *Queries) RetrieveDistinctSBOMDeps(ctx context.Context) ([]RetrieveDistinctSBOMDepsRow, error) {
rows, err := q.db.QueryContext(ctx, retrieveDistinctSBOMDeps)
if err != nil {
return nil, err
}
defer rows.Close()
var items []RetrieveDistinctSBOMDepsRow
for rows.Next() {
var i RetrieveDistinctSBOMDepsRow
if err := rows.Scan(
&i.PackageName,
&i.Version,
&i.CurrentVersion,
&i.PackageType,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}