Priscope
A security tool designed to help review merged code changes to open source maintained repositories via LLM assisted review to safeguard against supply chain attacks
Install / Use
/learn @marklechner/PriscopeREADME
PRIscope: PR Inspector for Security Concerns and Open-source Protection
PRIscope is a Python-based tool designed to analyze the history of code changes in open-source repositories primarily to address sowtware supply chain risks. It helps identify potential security risks or malicious code modifications by examining merged pull requests using an AI-powered code analysis.
<img src="_assets/sample.png" alt="example" width="800"/>IMPORTANT DISCLAIMER: PRIscope's effectiveness may be limited when using models with small context window sizes. For optimal performance, please refer to the "Ollama Configuration for Larger Context Windows" section below.
Features
- Fetches and analyzes the most recent merged pull requests from a specified GitHub repository.
- Utilizes Ollama, a local AI model server, for intelligent code analysis.
- Provides a concise summary of potential security risks for each analyzed pull request.
- Generates an optional JSON report with detailed findings.
- Can be run as a standalone Python script or within a Docker container.
Prerequisites
- Python 3.9 or higher
- Ollama installed and running locally via
ollama serve - The
mistral-smallmodel loaded in Ollama (recommended for its code analysis capabilities) - Docker (optional, for containerized usage)
Installation
-
Clone the repository:
git clone https://github.com/yourusername/priscope.git cd priscope -
Install the required Python packages:
pip install -r requirements.txt -
Ensure Ollama is installed and running with the
mistral-smallor similar model:ollama run mistral-small
Configuration
Edit the config.json file to set your preferences:
Usage
Running as a Python Script
To analyze a GitHub repository:
python priscope.py https://github.com/owner/repo [-n NUMBER | -s SINCE] [-j]
- Replace
https://github.com/owner/repowith the target repository URL. -n NUMBERspecifies the number of recent PRs to analyze (default is 10).-s SINCEanalyzes PRs merged since this time (format: 2d, 3w, 1m for days, weeks, months).-jgenerates a JSON report (optional).
Running with Docker
PRIscope can also be run in a Docker container for enhanced security and isolation. This method ensures that the script runs in a controlled environment with read-only access to the filesystem.
-
Build the Docker image:
docker build -t priscope . -
Run the container:
docker run --rm -v $(pwd):/app/output:rw --read-only -u $(id -u):$(id -g) priscope https://github.com/owner/repo -n 5 -jThis command does the following:
- Mounts the current directory to
/app/outputin the container for report output. - Sets the container's filesystem as read-only for security.
- Runs the container as the current user to ensure proper file permissions.
- Mounts the current directory to
Output
PRIscope provides a color-coded console output for each analyzed PR:
- Green: No issues identified
- Red: Potential security risk detected
If the JSON report option is used, a detailed report will be generated in the current directory (or /app/output when using Docker).
Why Mistral-Small?
I recommend using the mistral-small model with Ollama for several reasons:
- It demonstrates strong capabilities in code analysis and understanding.
- It offers a good balance between performance and resource requirements.
However, you can experiment with other models by changing the model_name in the config.json file.
Ollama Configuration for Larger Context Windows
By default, Ollama templates are configured with a context window of 2048 tokens. However, this can be quite small when analyzing larger PRs. It is highly recommended to extend this context window for better performance.
To increase the context window size:
-
Generate the model config:
ollama show mistral-small --modelfile > ollama_conf.txt -
Edit the
ollama_conf.txtfile by appending the following line right below theFROM ...line:PARAMETER num_ctx 32768This sets the context window to 128k tokens (the maximum for mistral-small).
-
Build a new model template:
ollama create mistral-small-128K -f ollama_conf.txt -
Update your
config.jsonfile with the new model name:{ "model_name": "mistral-small-128K" }
A sample ollama_conf.txt file is included in the repository for reference.
Contributing
Contributions to PRIscope are welcome! Please feel free to submit pull requests, report bugs, or suggest features.
Disclaimer
PRIscope is a tool designed to assist in identifying potential security risks, but it should not be considered a comprehensive security solution. Always perform thorough code reviews and use additional security measures in your development process.
Related Skills
diffs
344.4kUse the diffs tool to produce real, shareable diffs (viewer URL, file artifact, or both) instead of manual edit summaries.
clearshot
Structured screenshot analysis for UI implementation and critique. Analyzes every UI screenshot with a 5×5 spatial grid, full element inventory, and design system extraction — facts and taste together, every time. Escalates to full implementation blueprint when building. Trigger on any digital interface image file (png, jpg, gif, webp — websites, apps, dashboards, mockups, wireframes) or commands like 'analyse this screenshot,' 'rebuild this,' 'match this design,' 'clone this.' Skip for non-UI images (photos, memes, charts) unless the user explicitly wants to build a UI from them. Does NOT trigger on HTML source code, CSS, SVGs, or any code pasted as text.
openpencil
2.0kThe world's first open-source AI-native vector design tool and the first to feature concurrent Agent Teams. Design-as-Code. Turn prompts into UI directly on the live canvas. A modern alternative to Pencil.
ui-ux-pro-max-skill
56.5kAn AI SKILL that provide design intelligence for building professional UI/UX multiple platforms
