- Use Google Distroless images for all services (Go & Node.js). - Standardize documentation with [PROJECT-NAME].md. - Add .dockerignore and .gitignore to all projects. - Remove docker-compose.yml in favor of docker run instructions. - Fix Go version and dependency issues in observability, repo-integrations, and security-governance. - Add Podman support (fully qualified image names). - Update Dashboard to use Node.js static server for Distroless compatibility.
226 lines
5.2 KiB
Go
226 lines
5.2 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: query.sql
|
|
|
|
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createAuditLog = `-- name: CreateAuditLog :one
|
|
INSERT INTO audit_logs (actor_id, action, resource_type, resource_id, details)
|
|
VALUES ($1, $2, $3, $4, $5)
|
|
RETURNING id, timestamp, actor_id, action, resource_type, resource_id, details
|
|
`
|
|
|
|
type CreateAuditLogParams struct {
|
|
ActorID string `json:"actor_id"`
|
|
Action string `json:"action"`
|
|
ResourceType pgtype.Text `json:"resource_type"`
|
|
ResourceID pgtype.Text `json:"resource_id"`
|
|
Details []byte `json:"details"`
|
|
}
|
|
|
|
func (q *Queries) CreateAuditLog(ctx context.Context, arg CreateAuditLogParams) (AuditLog, error) {
|
|
row := q.db.QueryRow(ctx, createAuditLog,
|
|
arg.ActorID,
|
|
arg.Action,
|
|
arg.ResourceType,
|
|
arg.ResourceID,
|
|
arg.Details,
|
|
)
|
|
var i AuditLog
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Timestamp,
|
|
&i.ActorID,
|
|
&i.Action,
|
|
&i.ResourceType,
|
|
&i.ResourceID,
|
|
&i.Details,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createControl = `-- name: CreateControl :one
|
|
INSERT INTO controls (policy_id, name, description)
|
|
VALUES ($1, $2, $3)
|
|
RETURNING id, policy_id, name, description, created_at, updated_at
|
|
`
|
|
|
|
type CreateControlParams struct {
|
|
PolicyID pgtype.UUID `json:"policy_id"`
|
|
Name string `json:"name"`
|
|
Description pgtype.Text `json:"description"`
|
|
}
|
|
|
|
func (q *Queries) CreateControl(ctx context.Context, arg CreateControlParams) (Control, error) {
|
|
row := q.db.QueryRow(ctx, createControl, arg.PolicyID, arg.Name, arg.Description)
|
|
var i Control
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.PolicyID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createFinding = `-- name: CreateFinding :one
|
|
INSERT INTO findings (control_id, resource_id, status, details)
|
|
VALUES ($1, $2, $3, $4)
|
|
RETURNING id, control_id, resource_id, status, details, created_at, updated_at
|
|
`
|
|
|
|
type CreateFindingParams struct {
|
|
ControlID pgtype.UUID `json:"control_id"`
|
|
ResourceID string `json:"resource_id"`
|
|
Status FindingStatus `json:"status"`
|
|
Details []byte `json:"details"`
|
|
}
|
|
|
|
func (q *Queries) CreateFinding(ctx context.Context, arg CreateFindingParams) (Finding, error) {
|
|
row := q.db.QueryRow(ctx, createFinding,
|
|
arg.ControlID,
|
|
arg.ResourceID,
|
|
arg.Status,
|
|
arg.Details,
|
|
)
|
|
var i Finding
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ControlID,
|
|
&i.ResourceID,
|
|
&i.Status,
|
|
&i.Details,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createPolicy = `-- name: CreatePolicy :one
|
|
INSERT INTO policies (name, description)
|
|
VALUES ($1, $2)
|
|
RETURNING id, name, description, created_at, updated_at
|
|
`
|
|
|
|
type CreatePolicyParams struct {
|
|
Name string `json:"name"`
|
|
Description pgtype.Text `json:"description"`
|
|
}
|
|
|
|
func (q *Queries) CreatePolicy(ctx context.Context, arg CreatePolicyParams) (Policy, error) {
|
|
row := q.db.QueryRow(ctx, createPolicy, arg.Name, arg.Description)
|
|
var i Policy
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const createSecurityProfile = `-- name: CreateSecurityProfile :one
|
|
INSERT INTO security_profiles (name, risk_level)
|
|
VALUES ($1, $2)
|
|
RETURNING id, name, risk_level, created_at, updated_at
|
|
`
|
|
|
|
type CreateSecurityProfileParams struct {
|
|
Name string `json:"name"`
|
|
RiskLevel RiskLevel `json:"risk_level"`
|
|
}
|
|
|
|
func (q *Queries) CreateSecurityProfile(ctx context.Context, arg CreateSecurityProfileParams) (SecurityProfile, error) {
|
|
row := q.db.QueryRow(ctx, createSecurityProfile, arg.Name, arg.RiskLevel)
|
|
var i SecurityProfile
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.RiskLevel,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listAuditLogs = `-- name: ListAuditLogs :many
|
|
SELECT id, timestamp, actor_id, action, resource_type, resource_id, details FROM audit_logs
|
|
ORDER BY timestamp DESC
|
|
LIMIT $1 OFFSET $2
|
|
`
|
|
|
|
type ListAuditLogsParams struct {
|
|
Limit int32 `json:"limit"`
|
|
Offset int32 `json:"offset"`
|
|
}
|
|
|
|
func (q *Queries) ListAuditLogs(ctx context.Context, arg ListAuditLogsParams) ([]AuditLog, error) {
|
|
rows, err := q.db.Query(ctx, listAuditLogs, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []AuditLog
|
|
for rows.Next() {
|
|
var i AuditLog
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Timestamp,
|
|
&i.ActorID,
|
|
&i.Action,
|
|
&i.ResourceType,
|
|
&i.ResourceID,
|
|
&i.Details,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listFindings = `-- name: ListFindings :many
|
|
SELECT id, control_id, resource_id, status, details, created_at, updated_at FROM findings
|
|
WHERE status = $1
|
|
`
|
|
|
|
func (q *Queries) ListFindings(ctx context.Context, status FindingStatus) ([]Finding, error) {
|
|
rows, err := q.db.Query(ctx, listFindings, status)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Finding
|
|
for rows.Next() {
|
|
var i Finding
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ControlID,
|
|
&i.ResourceID,
|
|
&i.Status,
|
|
&i.Details,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|