- 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.
34 lines
785 B
Go
34 lines
785 B
Go
package audit
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
"github.com/lab/security-governance-core/internal/db"
|
|
)
|
|
|
|
type Logger struct {
|
|
queries *db.Queries
|
|
}
|
|
|
|
func NewLogger(queries *db.Queries) *Logger {
|
|
return &Logger{queries: queries}
|
|
}
|
|
|
|
func (l *Logger) Log(ctx context.Context, actorID, action, resourceType, resourceID string, details interface{}) error {
|
|
detailsJSON, err := json.Marshal(details)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
_, err = l.queries.CreateAuditLog(ctx, db.CreateAuditLogParams{
|
|
ActorID: actorID,
|
|
Action: action,
|
|
ResourceType: pgtype.Text{String: resourceType, Valid: resourceType != ""},
|
|
ResourceID: pgtype.Text{String: resourceID, Valid: resourceID != ""},
|
|
Details: detailsJSON,
|
|
})
|
|
|
|
return err
|
|
}
|