Skip to content

DevGuard Backend - Secure your Software Supply Chain - Attestation-based compliance as Code, manage your CVEs seamlessly, Integrate your Vulnerability Scanners, Security Framework Documentation made easy - OWASP Incubating Project

License

Notifications You must be signed in to change notification settings

l3montree-dev/devguard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


DevGuard by L3montree Logo

DevGuard - Develop Secure Software - Backend

Manage your CVEs seamlessly, Integrate your Vulnerability Scanners, Documentation made easy, Compliance to security Frameworks

Report Bug Β· Request Feature Β· Sponsors

OpenSSF Badge License CVSS

Get in touch with the developers directly via Matrix-Chat

Visit the Documentation at: https://devguard.org

Mission

DevGuard is built by developers, for developers, aiming to simplify the complex world of vulnerability management. Our goal is to integrate security seamlessly into the software development lifecycle, ensuring that security practices are accessible and efficient for everyone, regardless of their security expertise.

Demo

We are using DevGuard to scan and manage the risks of DevGuard itselfβ€”essentially eating our own dogfood. The project can be found here:

DEMO

We believe VEX information should be shared via a link due to its dynamic nature, as what is risk-free today may be affected by a CVE tomorrow. We've integrated the DevGuard risk scoring into the metrics, with detailed documentation on its calculation to follow soon. SBOM and VEX data are always up to date at these links:

Project SBOM VeX
Devguard Golang API SBOM VeX
Devguard Web-Frontend SBOM VeX

The problem we solve

Identifying and managing software vulnerabilities is an increasingly critical challenge. Developers often face security issues without the proper training or tools that fit into their everyday workflows. DevGuard is a developer-centered software designed to provide simple, modern solutions for vulnerability detection and management, compliant with common security frameworks.

In 2023 alone, cyberattacks caused approximately 206 billion euros in damage only in Germany. Many of these attacks exploited software vulnerabilities. With agile and DevOps methodologies becoming standard, the need for integrating security into the development process has never been greater. We aim to fill this gap with DevGuard, offering a seamless integration of vulnerability management into development workflows.

Contributing

We welcome contributions! Please read our contribution guide if you would like to report a bug, ask a question, write issues, or help us with coding. All help is appreciated!

(back to top)

Code of Conduct

Help us keep DevGuard open and inclusive. Please read and follow our Code of Conduct.

(back to top)

Built With

DevGuard is divided into two projects: A frontend (DevGuard Web) and a backend (DevGuard Backend).

Backend (this project):

  • Go

Frontend:

(back to top)

Database Migrations

DevGuard uses golang-migrate for database schema management. All migrations are embedded in the binary and run automatically on startup.

How Database Migrations Work

  1. Automatic Migration: By default, migrations run automatically when the application starts
  2. Environment Control: Set AUTO_MIGRATE=false to disable automatic migrations
  3. Embedded Migrations: Migration files are embedded in the binary for easy deployment
  4. Idempotent: Migrations can be run multiple times safely

Creating New Migrations

1. Install the Migration Tool

The project includes golang-migrate as a tool dependency. Install it using:

go get -tool github.com/golang-migrate/migrate/v4/cmd/migrate

2. Create a New Migration

# Create a new migration file pair (.up.sql and .down.sql)
go tool migrate create -ext sql -dir internal/database/migrations your_migration_name

# Example: Adding a new table
go tool migrate create -ext sql -dir internal/database/migrations add_user_preferences_table

This creates two files:

  • internal/database/migrations/YYYYMMDDHHMMSS_your_migration_name.up.sql - Forward migration
  • internal/database/migrations/YYYYMMDDHHMMSS_your_migration_name.down.sql - Rollback migration

3. Write Your Migration

Example: Adding a new table

20250801120000_add_user_preferences_table.up.sql:

-- Create user preferences table
CREATE TABLE IF NOT EXISTS user_preferences (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id TEXT NOT NULL,
    theme TEXT DEFAULT 'light',
    notifications_enabled BOOLEAN DEFAULT true,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);

-- Add index for faster lookups
CREATE INDEX IF NOT EXISTS idx_user_preferences_user_id ON user_preferences(user_id);

20250801120000_add_user_preferences_table.down.sql:

-- Remove the user preferences table
DROP TABLE IF EXISTS user_preferences CASCADE;

Example: Adding a column

20250801130000_add_email_to_users.up.sql:

-- Add email column to existing users table
ALTER TABLE users ADD COLUMN IF NOT EXISTS email TEXT;

-- Add index for email lookups
CREATE INDEX IF NOT EXISTS idx_users_email ON users(email);

20250801130000_add_email_to_users.down.sql:

-- Remove email column from users table
ALTER TABLE users DROP COLUMN IF EXISTS email CASCADE;

Example: Adding foreign key constraints

20250801140000_add_user_organization_fk.up.sql:

-- Add foreign key constraint
ALTER TABLE users 
ADD CONSTRAINT IF NOT EXISTS fk_users_organization 
FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE;

20250801140000_add_user_organization_fk.down.sql:

-- Remove foreign key constraint
ALTER TABLE users DROP CONSTRAINT IF EXISTS fk_users_organization;

4. Best Practices

  • Always use IF NOT EXISTS/IF EXISTS: Makes migrations idempotent
  • Include rollback logic: Always write the down migration
  • Test migrations: Test both up and down migrations on a copy of production data
  • Small incremental changes: Keep migrations focused and atomic
  • Use transactions implicitly: PostgreSQL wraps DDL in transactions automatically
  • Descriptive names: Use clear, descriptive migration names

5. Manual Migration Commands

# Check migration status
go tool migrate -database "postgres://user:pass@localhost:5432/devguard?sslmode=disable" -path internal/database/migrations version

# Run migrations manually
go tool migrate -database "postgres://user:pass@localhost:5432/devguard?sslmode=disable" -path internal/database/migrations up

# Rollback one migration
go tool migrate -database "postgres://user:pass@localhost:5432/devguard?sslmode=disable" -path internal/database/migrations down 1

# Rollback to specific version
go tool migrate -database "postgres://user:pass@localhost:5432/devguard?sslmode=disable" -path internal/database/migrations goto 20250801120000

(back to top)

License

Distributed under the AGPL-3.0-or-later License. See LICENSE.txt for more information.

(back to top)

Sponsors and Supporters πŸš€

We are proud to be supported and working together with the following organizations:

OWASP Bonn-Rhein-Sieg University of Applied Science WhereGroup DigitalHub WetterOnline Ikor

(back to top)

DEVGUARD-SCANNER

Build the scanner

docker build . -f Dockerfile.scanner -t devguard-scanner  

Use the scanner for sca

docker run -v "$(PWD):/app" scanner devguard-scanner sca \
  --assetName="<ASSET NAME>" \
  --apiUrl="http://host.docker.internal:8080" \
  --token="<TOKEN>" \
  --path="/app"

Using the scanner during development

go run ./cmd/devguard-scanner/main.go sca \
  --assetName="<ASSET NAME>" \
  --apiUrl="http://localhost:8080" \
  --token="<TOKEN>"

Scan a container

Build a image.tar from a dockerfile using kaniko
docker run --rm -v $(pwd):/workspace gcr.io/kaniko-project/executor:latest --dockerfile=/workspace/Dockerfile --context=/workspace --tarPath=/workspace/image.tar --no-push
Scan the .tar
docker run -v "$(PWD):/app" scanner devguard-scanner container-scanning \
  --assetName="<ASSET NAME>" \
  --apiUrl="http://host.docker.internal:8080" \
  --token="<TOKEN>" \
  --path="/app/image.tar"

About

DevGuard Backend - Secure your Software Supply Chain - Attestation-based compliance as Code, manage your CVEs seamlessly, Integrate your Vulnerability Scanners, Security Framework Documentation made easy - OWASP Incubating Project

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors 11