-
Notifications
You must be signed in to change notification settings - Fork 1
feat(sqlite): support SQLite alongside PostgreSQL in the vulnerability queries #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1a386ea
5839c00
b4fea82
f038a2b
919a1f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,13 +37,18 @@ APP_PORT=50052 | |
| APP_MODE=dev | ||
| APP_DEBUG=false | ||
|
|
||
| DB_DRIVER=postgres | ||
| DB_DRIVER=postgres # postgres or sqlite | ||
| DB_HOST=localhost | ||
| DB_USER=scanoss | ||
| DB_PASSWD= | ||
| DB_SCHEMA=vulnerabilities | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 6 'DB_SCHEMA|Database\.Schema|cfg\.Database\.Schema' README.md pkg/config
rg -n -C 6 'DB_DSN|Dsn|Schema' pkg/config --glob '*.go'Repository: scanoss/vulnerabilities Length of output: 4222 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- README configuration context ---'
sed -n '28,58p' README.md
printf '%s\n' '--- configuration source outline and relevant code ---'
ast-grep outline pkg/config/server_config.go
sed -n '1,155p' pkg/config/server_config.go
printf '%s\n' '--- all schema and DSN references ---'
rg -n -C 4 'Database\.Schema|DB_SCHEMA|schema|DB_DSN|Dsn|New.*DSN|postgres|sqlite' --glob '*.go' --glob '*.md' --glob '*.yml' --glob '*.yaml' --glob '*.env*' .
printf '%s\n' '--- database-related files ---'
git ls-files | rg '(^|/)(database|db|migration|migrations|.*config.*|.*schema.*)' | head -200Repository: scanoss/vulnerabilities Length of output: 50381 🏁 Script executed: #!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
import re
files = [p for p in Path('.').rglob('*') if p.is_file() and p.stat().st_size < 2_000_000]
patterns = {
'schema_field': re.compile(r'\b(?:Database\.)?Schema\b|DB_SCHEMA'),
'dsn_field': re.compile(r'\b(?:Database\.)?Dsn\b|DB_DSN'),
}
for label, pattern in patterns.items():
print(f'--- {label} ---')
for path in files:
try:
text = path.read_text(errors='replace')
except Exception:
continue
for i, line in enumerate(text.splitlines(), 1):
if pattern.search(line):
print(f'{path}:{i}:{line.strip()}')
PY
PYRepository: scanoss/vulnerabilities Length of output: 1208 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- configuration examples ---'
for f in config/app-config-dev.json config/app-config-prod.json config/app-config-docker-local-dev.json .env.example; do
if [ -f "$f" ]; then
echo "--- $f"
cat -n "$f"
fi
done
printf '%s\n' '--- dependency declaration ---'
rg -n -C 3 'go-grpc-helper|module ' go.mod go.sum
printf '%s\n' '--- focused database-call context ---'
sed -n '92,120p' pkg/cmd/server.go
rg -n -C 3 'OpenDBConnection' --glob '*.go' .Repository: scanoss/vulnerabilities Length of output: 5000 🌐 Web query:
💡 Result: In the SCANOSS Citations:
Set When 🤖 Prompt for AI Agents |
||
| DB_SSL_MODE=disable | ||
|
|
||
| # To run against SQLite instead, point DB_DSN at the database file. | ||
| # The remaining DB_* values are only used to build a DSN when DB_DSN is empty. | ||
| # DB_DRIVER=sqlite | ||
| # DB_DSN=/path/to/vulnerabilities.db | ||
|
|
||
| # Vulnerability data sources | ||
| OSV_ENABLED=true # Enable/disable OSV (Open Source Vulnerabilities) database | ||
| OSV_API_BASE_URL=https://api.osv.dev/v1 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // SPDX-License-Identifier: GPL-2.0-or-later | ||
| /* | ||
| * Copyright (C) 2018-2025 SCANOSS.COM | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 2 of the License, or | ||
| * (at your option) any later version. | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| // Helpers shared by the tests in this package. They live in a _test.go file so they do | ||
| // not ship in the binary; LoadTestSchema and LoadTestSQLData stay in common.go because | ||
| // tests in other packages call them. | ||
|
|
||
| package models | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/jmoiron/sqlx" | ||
| ) | ||
|
|
||
| // loadTestSQLDataFilesWithSchema loads the production schema followed by the given data | ||
| // fixtures. Use this instead of loadTestSQLDataFiles when a test only needs a subset of | ||
| // the fixtures, since the fixtures do not create their own tables. | ||
| func loadTestSQLDataFilesWithSchema(db *sqlx.DB, ctx context.Context, conn *sqlx.Conn, files []string) error { | ||
| if err := LoadTestSchema(db, ctx, conn); err != nil { | ||
| return err | ||
| } | ||
| return loadTestSQLDataFiles(db, ctx, conn, files) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add the missing
0.14.0changelog reference.Line 11 uses a reference-style version heading, but the reference list at the end stops at
[0.13.0]. The0.14.0heading therefore does not render as a comparison link. Add the release reference after the existing[0.13.0]definition.Proposed fix
[0.13.0]: https://github.com/scanoss/vulnerabilities/compare/v0.12.0...v0.13.0 +[0.14.0]: https://github.com/scanoss/vulnerabilities/compare/v0.13.0...v0.14.0🤖 Prompt for AI Agents