Replace CGO-based sqlite3 driver with pure-Go modernc.org/sqlite#72
Replace CGO-based sqlite3 driver with pure-Go modernc.org/sqlite#72Copilot wants to merge 2 commits into
Conversation
Co-authored-by: karam-ajaj <37446151+karam-ajaj@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the SQLite database driver from the CGO-based github.com/mattn/go-sqlite3 to the pure Go implementation modernc.org/sqlite. This eliminates the CGO dependency, simplifying builds and improving portability.
- Replaced all import statements from
github.com/mattn/go-sqlite3tomodernc.org/sqlite - Updated all
sql.Open()calls to use driver name "sqlite" instead of "sqlite3" - Removed the
sqlite3CLI tool from the Dockerfile as it's no longer needed for the Go driver
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| config/atlas_go/go.mod | Updated primary dependency from go-sqlite3 to modernc.org/sqlite with transitive dependencies |
| config/atlas_go/go.sum | Updated checksums reflecting the new driver and its dependencies |
| config/atlas_go/internal/scan/fastscan.go | Changed import and driver name in two sql.Open() calls |
| config/atlas_go/internal/scan/docker_scan.go | Changed import and driver name in sql.Open() call |
| config/atlas_go/internal/scan/deep_scan.go | Changed import and driver name in sql.Open() call |
| config/atlas_go/internal/db/setup.go | Changed import and driver name in sql.Open() call |
| Dockerfile | Removed sqlite3 CLI tool from apt-get install list |
| RUN apt-get update && \ | ||
| apt-get install -y \ | ||
| nginx iputils-ping traceroute nmap sqlite3 net-tools curl jq ca-certificates nbtscan docker.io && \ | ||
| nginx iputils-ping traceroute nmap net-tools curl jq ca-certificates nbtscan docker.io && \ |
There was a problem hiding this comment.
The removal of sqlite3 CLI tool may impact debugging workflows. The documentation in .github/copilot-instructions.md and MIGRATION_GUIDE.md still references using sqlite3 /config/db/atlas.db for inspecting the database. Consider updating those documentation files to use an alternative method (e.g., mounting a volume and using sqlite3 from the host, or installing a SQLite CLI tool separately) or add a note that the sqlite3 CLI is no longer available in the container.
| nginx iputils-ping traceroute nmap net-tools curl jq ca-certificates nbtscan docker.io && \ | |
| nginx iputils-ping traceroute nmap net-tools curl jq ca-certificates nbtscan docker.io sqlite3 && \ |
Eliminates CGO dependency and system sqlite3 package to remove C toolchain requirement and reduce image CVEs.
Changes
Dependencies
go.mod:github.com/mattn/go-sqlite3 v1.14.17→modernc.org/sqlite v1.40.0Driver registration (4 files)
_ "github.com/mattn/go-sqlite3"→_ "modernc.org/sqlite"internal/db/setup.go,internal/scan/{docker_scan,deep_scan,fastscan}.goDriver name (5 callsites)
sql.Open("sqlite3", path)→sql.Open("sqlite", path)Container runtime
Dockerfile: Removedsqlite3from apt packagesExample
No API changes. DSN format and SQL semantics unchanged.
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.