Terminal UI for Trivy scanning, written in C with ncurses.
It guides filesystem or Docker image scans and presents colorized, scrollable results for
vulnerabilities, secrets, and licenses.
Built as over-the-holidays project to scare my sysadmin colleagues. :)
Utility and convenience might also been my goals but scaring was definitely up there.
Version 0.9.3 - Reports now display descriptions correctly. Fixed versions troughout.
Version 0.9.2 - Added airgapped scripts
Version 0.9.1 - Security hardened with comprehensive input validation, buffer overflow protection, and improved code quality.
Version 0.9.0 - Initial release build
Tested in Rocky Linux 8.10, Ubuntu 24.04 LTS and Debian 13.2.
This was done for my purposes, any feature or enhancement suggestions are welcome.
- Scan History View: Quick overview of recent scans with security scores and severity breakdowns.
- Guided filesystem and image scans with a simple curses UI.
- Search & Filter: Real-time search through results (press
/) with case-insensitive filtering. - Multiple Export Formats: Export to JSON, HTML (with embedded CSS), or Markdown (press
x). - Automatic History Tracking: Records last 10 scans with scores and vulnerability counts.
- Settings to toggle secrets/licenses scanning, set severity/ignore filters, configure timeouts and root-skip dirs, and refresh the DB when online.
- Auto-start scan summary with DB status before running, plus rescan last target.
- Main menu footer shows detected Trivy and DB versions.
- Save report output to a file and view the last error log.
- Colorized summary, severity score, and readable detail view.
- Works with older Trivy versions by falling back to supported flags.
- Input Validation: Command injection prevention with strict input sanitization
- Path Traversal Protection: Directory listing validates against malicious paths
- Buffer Overflow Prevention: Size checks before string operations and proper null termination
- Integer Overflow Checks: Safe buffer allocation with overflow detection
- Race Condition Fixes: Proper file descriptor handling in subprocess communication
- Reduced Global State: Application context structure for better code organization
- Comprehensive Documentation: Doxygen-style comments throughout codebase
- Linux. (Tested in Rocky Linux and Ubuntu.)
- Build deps:
ncursesandjanssondevelopment headers. - Trivy in
PATH(install manually). - Docker optional (only needed for image scans).
# Rocky/RHEL/CentOS
sudo dnf -y groupinstall -y "Development Tools"
sudo dnf -y install -y ncurses-devel jansson-devel
# Debian/Ubuntu
sudo apt-get update
sudo apt-get install -y build-essential libncurses-dev libjansson-dev# Build
gcc -std=c11 -Wall -Wextra -pedantic main.c -lncurses -ljansson -lm -o trivytui
# Or use the Makefile
make
# Run unit tests
make test
# Install (default: /usr/local/bin)
sudo make install
# Alt install (default: /opt/trivytui/bin)
sudo make altinstall
# Run
./trivytui # Use sudo for access to some filesystems and/or dockerBinary builds are provided in Releases.
The project uses automated version detection:
- Git tags (preferred): Version is automatically extracted from git tags
- Manual override: Use
VERSION=x.x.xfor custom versions - Hardcoded fallback: Uses version 0.9.3 if no tags exist
# Check detected version
make show-version
# Build with auto-detected version (from git tags or fallback)
make
# Build with specific version
make VERSION=1.0.0
# Create a new release
git tag -a v0.9.4 -m "Release v0.9.4"
git push origin v0.9.4
make # Automatically uses 0.9.4
# Check binary version
./trivytui --versionTo create RPM and DEB packages (requires Rocky Linux 8.10 or compatible):
# Build with auto-detected version
sudo make packages
# Build with specific version
sudo make packages VERSION=0.9.4Packages will be created in build/ directory:
- trivytui-0.9.3-1.el8.x86_64.rpm
- trivytui_0.9.3-1_amd64.deb
- trivytui-0.9.3.tar.gz
- SHA256SUMS
The packaging script uses:
rpmbuildfor RPM creation- Manual
ar+tarfor DEB creation (no dpkg-deb required) - Comprehensive checksums for verification
The project now includes unit tests covering:
- Input validation (command injection prevention)
- Path traversal detection
- Buffer overflow prevention logic
- Integer overflow checks
- Severity score calculation
- Basic data structure operations
Run tests with:
make test
# or
make check- Arrows + Enter to navigate;
eexits - Shows Trivy/DB versions at bottom
- Options: Filesystem scan, Image scan, Rescan last target, History, Settings, Exit
- History menu item shows " - (empty)" when no scans have been performed
- Shows overview of most recent scan with security score (0-100)
- Color-coded severity breakdown with bar charts
- List of up to 5 recent scans with scores
- Security score interpretation:
- 90-100: Excellent (green/cyan)
- 70-89: Good (yellow)
- 50-69: Fair (magenta)
- 0-49: Poor (red)
- Press any key to return to main menu
- Enter opens directory
- Space selects current path
bback,mmain menu,eexit
- Arrows + Enter select image
- Last selection remembered
bback,mmain menu,eexit
- Auto-starts after 5 seconds
- Enter to start immediately
b/cback,mmenu,eexit
Navigation:
- Arrows/
j/kscroll line by line - PgUp/PgDn jump by page
nnext occurrence,Nprevious
Search & Filter:
/open search prompt- Enter search term (case-insensitive)
cclear current filter- Status line shows
Filter: 'term' (X/Y lines)
Export:
xopen export menu- Choose format: JSON, HTML, or Markdown
- HTML: Styled report with embedded CSS (email-friendly)
- Markdown: GitHub/GitLab compatible with emoji badges
slegacy JSON save (kept for compatibility)
Other:
bback to pickermreturn to main menueexit application
- Toggle secrets/licenses scanning
- Set severity threshold (All/Low+/Medium+/High+/Critical)
- Configure ignore file, timeout, root-skip dirs
- Redownload DB (requires internet)
- View last error log
- History stores last 10 scans in memory (not persisted between sessions).
- Security scores use exponential decay formula:
100 * exp(-0.0025 * weighted_count). - DB update is available from Settings and requires internet connectivity.
- Docker required for image scans; filesystem scans work without Docker.
- License scanning uses Trivy's
--scannersand--license-fullflags when available, and falls back for older versions. - Ignore file uses Trivy's
--ignorefileformat. - Root skip dirs apply only when scanning
/and are configurable in Settings. - Saved reports are raw Trivy JSON output.
- Saved reports append
.jsonif missing. - Default root skip dirs:
/proc,/sys,/run,/dev,/var/lib/docker,/var/lib/containers. - Although it allows full filesystem scan, it is slow and probably not useful.
If Trivy is not installed, install it manually:
# Preferred (needs curl + sudo)
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh \
| sudo sh -s -- -b /usr/local/bin
# Without sudo, install into $HOME/.local/bin
mkdir -p ~/.local/bin
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh \
| sh -s -- -b ~/.local/bin
echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
# Verify
trivy --version
trivy image --download-db-only --no-progressTwo helper scripts are provided under airgap/ to stage Trivy and its DB on a connected machine and install them on an airgapped host.
1) On a machine with internet:
# Downloads latest Trivy release assets + DB cache into ./airgap
bash airgap/stage-download-trivy.shThis produces trivy-cache.tgz plus platform packages (RPM/DEB) and a tarball.
2) Transfer files to the airgapped machine:
trivy_*.deb(Ubuntu/Debian) ortrivy_*.rpm(RHEL/Fedora)trivy-cache.tgz- Optional:
trivy-offline-manifest.txtandtrivy-offline-sha256sums.txt
3) On the airgapped machine:
sudo bash airgap/airgap-install-trivy.shBy default, the cache is installed under /var/lib/trivy. Set TRIVY_CACHE_DIR to override.
The codebase follows these principles:
- Clear Documentation: Doxygen-style comments for all major functions and structures
- Named Constants: All magic numbers replaced with descriptive defines
- Error Handling: Consistent error checking and reporting
- Memory Safety: Proper allocation checks and cleanup
- Security First: All inputs validated, all buffers checked
main.c- Main application with UI and scanning logic (~2900 lines)test_trivytui.c- Unit tests for core functionalityMakefile- Build configuration with test support
Issues and pull requests welcome! When contributing:
- Follow the existing code style (K&R-ish with documentation)
- Add tests for new functionality
- Update README for user-facing changes
- Run
make testbefore submitting
License is CC0 1.0 Universal. Please do with this code as you see fit. If your country/region does not support CC0, consider the code as Public Domain.
Creates a self-contained HTML file with:
- Dark theme styling (VS Code inspired)
- Color-coded severity levels
- Responsive layout
- Embedded CSS (no external dependencies)
- Perfect for email attachments or offline viewing
GitHub/GitLab compatible format with:
- Emoji badges for severity levels (🔴 CRITICAL, 🟠 HIGH, 🟡 MEDIUM, 🔵 LOW)
- Proper heading hierarchy
- Easy to paste into issues/PRs
- Readable in any markdown viewer
Search for specific CVE: /CVE-2024-1234
Filter by package name: /openssl
Show only CRITICAL findings: /CRITICAL
Find secrets: /secret
Search in descriptions: /buffer overflow
- Fixed reporting errors if CVE text contained a script html tag.
- Added airgap helpers
- Fixed small bugs
- Fixed offline functionality
- Airgap staging and installation scripts added
- History view with scan tracking and security scores
- Automatic tracking of last 10 scans with statistics
- Color-coded severity bar charts in history view
- Dynamic menu labels showing history status
- Search & filter in report viewer (press
/) - Export to HTML and Markdown formats (press
x) - Interactive export format menu
- Real-time filter status display
- Security: Input validation, buffer overflow fixes, path traversal protection
- Quality: Reduced global state, comprehensive documentation, unit tests
- Refactoring: Named constants, improved error handling
- Testing: Unit test framework with coverage of security-critical code
- Initial release with filesystem and image scanning
- Interactive TUI with ncurses
- Trivy version detection and fallback support