Skip to main content

HAIstings

HAIstings is an AI-powered companion designed to help you assess and prioritize Common Vulnerabilities and Exposures (CVEs) within your Kubernetes infrastructure. Drawing inspiration from Agatha Christie's legendary character Arthur Hastings, the crime-solving partner of Hercule Poirot, HAIstings partners with you to ensure robust security measures in your Kubernetes environments.

Overview

HAIstings analyzes vulnerability reports from tools like trivy-operator, generates prioritized reports, and engages in an interactive conversation to refine its recommendations based on your specific context and requirements.

Features

  • Vulnerability Prioritization: Automatically prioritizes vulnerabilities based on severity, impact, and context
  • Interactive Refinement: Engages in a conversation to gather more context and refine prioritization
  • Infrastructure Context: Ingests infrastructure repository information to provide more relevant recommendations
  • Persistent Memory: Maintains conversation history across sessions using checkpoints
  • Customizable Output: Adjusts recommendations based on user-provided context
  • Retrieval-Augmented Generation (RAG): Selectively includes only relevant infrastructure files in the context, reducing overall context size and improving performance

Installation

Prerequisites

  • Python 3.12
  • Kubernetes cluster with trivy-operator installed
  • Properly configured kubeconfig file

Using Poetry

# Clone the repository
git clone https://github.com/stacklok/HAIstings.git
cd HAIstings

# Install dependencies
poetry install

Using pip

pip install haistings

Usage

Basic Usage

Generate a vulnerability report showing the top 25 most critical vulnerabilities:

haistings

Customizing Output

Specify the number of vulnerabilities to show:

haistings --top 30

Providing Context

Provide additional context to improve prioritization:

haistings --notes usercontext.txt

Where usercontext.txt contains information about your infrastructure, such as:

example-service is a very critical service that is internet-facing. We should assign more priority to it.

Flux is critical to our infrastructure, so if it has a vulnerability on anything related to how it processes git requests, then we should assign it very high priority.

Ingesting Infrastructure Repository

Provide your infrastructure repository for additional context:

haistings --infra-repo https://github.com/yourusername/infra-repo --gh-token YOUR_GITHUB_TOKEN

For a specific subdirectory:

haistings --infra-repo https://github.com/yourusername/infra-repo --infra-repo-subdir kubernetes --gh-token YOUR_GITHUB_TOKEN

RAG Configuration

Control the Retrieval-Augmented Generation functionality:

# Disable RAG (use traditional approach)
haistings --use-vectordb false

# Specify maximum number of relevant files per component
haistings --max-relevant-files 10

Persistent Conversations

Use SQLite to persist conversation history:

haistings --checkpoint-saver-driver sqlite

Full Example

haistings --top 30 --notes usercontext.txt --infra-repo https://github.com/yourusername/infra-repo --max-relevant-files 8 --checkpoint-saver-driver sqlite

How It Works

  1. Vulnerability Collection: HAIstings connects to your Kubernetes cluster and collects vulnerability reports from trivy-operator.
  2. Prioritization: Vulnerabilities are prioritized based on severity (critical vulnerabilities are weighted 10x more than high vulnerabilities).
  3. Repository Ingestion: Infrastructure repository files are ingested and stored in a vector database for efficient retrieval.
  4. Relevant File Retrieval: Using RAG (Retrieval-Augmented Generation), only the most relevant files for each vulnerability are retrieved based on similarity search.
  5. Context Integration: User-provided context and relevant infrastructure files are integrated into the analysis.
  6. Report Generation: A prioritized report is generated in a conversational style inspired by Arthur Hastings.
  7. Interactive Refinement: HAIstings engages in a conversation to gather more context and refine its recommendations.

Command Line Options

Option Description Default
--top Number of vulnerabilities to show 25
--notes Path to a file containing additional context None
--infra-repo URL to your infrastructure repository None
--infra-repo-subdir Subdirectory in the repository to ingest None
--gh-token GitHub Personal Access Token for private repositories None
--checkpoint-saver-driver Memory persistence driver (memory or sqlite) memory
--use-vectordb Use vector database for repository ingestion true
--max-relevant-files Maximum number of relevant files per component 5
--debug Enable debug mode False
--model LLM model to use (when not using CodeGate) this-makes-no-difference-to-codegate
--model-provider Model provider openai
--api-key API key for the model provider (when not using CodeGate) fake-api-key
--base-url Base URL for the model provider http://127.0.0.1:8989/v1/mux

Example Output

# HAIsting's Security Report

## Introduction

Good day! Arthur Hastings at your service. I've meticulously examined the vulnerability reports from your Kubernetes infrastructure and prepared a prioritized assessment of the security concerns that require your immediate attention.

## Summary

After careful analysis, I've identified several critical vulnerabilities that demand prompt remediation:

1. **example-service (internet-facing service)**
   - Critical vulnerabilities: 3
   - High vulnerabilities: 7
   - Most concerning: CVE-2023-1234 (Remote code execution)
   
   This service is particularly concerning due to its internet-facing nature, as mentioned in your notes. I recommend addressing these vulnerabilities with the utmost urgency.

2. **Flux (GitOps controller)**
   - Critical vulnerabilities: 2
   - High vulnerabilities: 5
   - Most concerning: CVE-2023-5678 (Git request processing vulnerability)
   
   As you've noted, Flux is critical to your infrastructure, and this Git request processing vulnerability aligns with your specific concerns.

[Additional entries...]

## Conclusion

I say, these vulnerabilities require prompt attention, particularly the ones affecting your internet-facing services and deployment controllers. I recommend addressing the critical vulnerabilities in example-service and Flux as your top priorities. Should you require any further assistance or have additional context to share, I remain at your service.

Development

Setting Up Development Environment

# Clone the repository
git clone https://github.com/stacklok/HAIstings.git
cd HAIstings

# Install dependencies including development dependencies
poetry install

# Run tests
poetry run pytest

Code Style

This project uses:

  • Black for code formatting
  • isort for import sorting
  • mypy for type checking
  • flake8 for linting
# Format code
poetry run black .
poetry run isort .

# Type check
poetry run mypy .

# Lint
poetry run flake8

Future Improvements / TODO

  • Custom Vulnerability Scoring: Add support for custom vulnerability scoring based on user-defined criteria beyond just severity.
  • Integration with More Scanners: Extend beyond trivy-operator to support other vulnerability scanners.
  • Visualization Dashboard: Create a web interface to visualize vulnerability reports and trends over time.
  • Automated Remediation Suggestions: Provide specific remediation steps for common vulnerabilities.
  • Multi-Cluster Support: Add support for analyzing vulnerabilities across multiple Kubernetes clusters.

License

Apache-2.0

Metadata

Release files for haistings 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for haistings 0.0.2
File Size Uploaded Provenance
haistings-0.0.2.tar.gz 19.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for haistings 0.0.2
File Interpreter ABI Platform
haistings-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 38.2 kB

Release files / haistings-0.0.2.tar.gz

Download URL haistings-0.0.2.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2542d9ed9df6001eb8c93c86fe3dfe301ca2f1fe1f5e95816c3a217500d6a75a
BLAKE2b-256 checksum
How to use checksums
73d40312dda3e3b1eb8f3d62d6304ef7d364b4ce510559b1924db369da111bc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 5, 2025.

Transparency log

Release files / haistings-0.0.2-py3-none-any.whl

Download URL haistings-0.0.2-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b0e9345258ef400d845d663a2c4d224d2aaa798cbb24ca4a394e82618793945
BLAKE2b-256 checksum
How to use checksums
c0931b675dd352ebd2e05b9b9da59a6845c80cfce31f868bf1e240e42ebdf454
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 5, 2025.

Transparency log

Security for haistings 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for haistings-0.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 5, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page