-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7e81641
Showing
26 changed files
with
1,915 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
## Issue | ||
|
||
### Description | ||
|
||
Please provide a detailed description of the issue or feature request. Include any relevant information, such as the context in which the issue occurs or the feature is needed. | ||
|
||
### Steps to Reproduce (for bug reports) | ||
|
||
1. Go to '...' | ||
2. Click on '...' | ||
3. Scroll down to '...' | ||
4. See error | ||
|
||
### Expected Behavior | ||
|
||
A clear and concise description of what you expected to happen. | ||
|
||
### Screenshots | ||
|
||
If applicable, add screenshots to help explain your problem. | ||
|
||
### Environment | ||
|
||
- OS: [e.g., Windows, macOS, Linux] | ||
- Burp Suite Version: [e.g., 2023.1] | ||
- Jython Version: [e.g., 2.7.4] | ||
- Other relevant environment details | ||
|
||
### Additional Context | ||
|
||
Add any other context about the problem here. | ||
|
||
### Feature Request | ||
|
||
If you are requesting a new feature, please describe the feature in detail and provide any relevant examples or use cases. | ||
|
||
### Contribution | ||
|
||
We welcome any forks and contributions, especially those that increase the number of supported "configs" through additional inference providers. Please ensure that your contributions follow the project's guidelines and include relevant tests and documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
🏴☠️ Burpference | ||
|
||
## Ahoy, Mateys! | ||
|
||
Ahoy, ye scurvy dogs, and welcome aboard Burpference! For non-forks, leave that there pull request description blank, and let [rigging](https://github.com/dreadnode/rigging) work its sorcery like a true sea wizard. Arrr! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
import asyncio | ||
import base64 | ||
import os | ||
import typing as t | ||
|
||
from pydantic import ConfigDict, StringConstraints | ||
|
||
import rigging as rg | ||
from rigging import logger | ||
from rigging.generator import GenerateParams, Generator, register_generator | ||
|
||
logger.enable("rigging") | ||
|
||
MAX_TOKENS = 8000 | ||
TRUNCATION_WARNING = "\n\n**Note**: Due to the large size of this diff, some content has been truncated." | ||
str_strip = t.Annotated[str, StringConstraints(strip_whitespace=True)] | ||
|
||
|
||
class PRDiffData(rg.Model): | ||
"""XML model for PR diff data""" | ||
|
||
content: str_strip = rg.element() | ||
|
||
@classmethod | ||
def xml_example(cls) -> str: | ||
return """<diff><content>example diff content</content></diff>""" | ||
|
||
|
||
class PRDecorator(Generator): | ||
"""Generator for creating PR descriptions""" | ||
|
||
model_config = ConfigDict(arbitrary_types_allowed=True, validate_assignment=True) | ||
|
||
api_key: str = "" | ||
max_tokens: int = MAX_TOKENS | ||
|
||
def __init__(self, model: str, params: rg.GenerateParams) -> None: | ||
api_key = params.extra.get("api_key") | ||
if not api_key: | ||
raise ValueError("api_key is required in params.extra") | ||
|
||
super().__init__(model=model, params=params, api_key=api_key) | ||
self.api_key = api_key | ||
self.max_tokens = params.max_tokens or MAX_TOKENS | ||
|
||
async def generate_messages( | ||
self, | ||
messages: t.Sequence[t.Sequence[rg.Message]], | ||
params: t.Sequence[GenerateParams], | ||
) -> t.Sequence[rg.GeneratedMessage]: | ||
responses = [] | ||
for message_seq, p in zip(messages, params): | ||
base_generator = rg.get_generator(self.model, params=p) | ||
llm_response = await base_generator.generate_messages([message_seq], [p]) | ||
responses.extend(llm_response) | ||
return responses | ||
|
||
|
||
register_generator("pr_decorator", PRDecorator) | ||
|
||
|
||
async def generate_pr_description(diff_text: str) -> str: | ||
"""Generate a PR description from the diff text""" | ||
diff_tokens = len(diff_text) // 4 | ||
if diff_tokens >= MAX_TOKENS: | ||
char_limit = (MAX_TOKENS * 4) - len(TRUNCATION_WARNING) | ||
diff_text = diff_text[:char_limit] + TRUNCATION_WARNING | ||
|
||
diff_data = PRDiffData(content=diff_text) | ||
params = rg.GenerateParams( | ||
extra={ | ||
"api_key": os.environ["OPENAI_API_KEY"], | ||
"diff_text": diff_text, | ||
}, | ||
temperature=0.1, | ||
max_tokens=500, | ||
) | ||
|
||
generator = rg.get_generator("pr_decorator!gpt-4-turbo-preview", params=params) | ||
prompt = f"""You are a helpful AI that generates clear and concise PR descriptions with some pirate tongue. | ||
Analyze the provided git diff and create a summary, specifically focusing on the elements of the code that | ||
has changed, high severity functions etc using exactly this format: | ||
### PR Summary | ||
#### Overview of Changes | ||
<overview paragraph> | ||
#### Key Modifications | ||
1. **<modification title>**: <description> | ||
(continue as needed) | ||
#### Potential Impact | ||
- <impact point 1> | ||
(continue as needed) | ||
Here is the PR diff to analyze: | ||
{diff_data.to_xml()}""" | ||
|
||
chat = await generator.chat(prompt).run() | ||
return chat.last.content.strip() | ||
|
||
|
||
async def main(): | ||
"""Main function for CI environment""" | ||
if not os.environ.get("OPENAI_API_KEY"): | ||
raise ValueError("OPENAI_API_KEY environment variable must be set") | ||
|
||
try: | ||
diff_text = os.environ.get("GIT_DIFF", "") | ||
if not diff_text: | ||
raise ValueError("No diff found in GIT_DIFF environment variable") | ||
|
||
try: | ||
diff_text = base64.b64decode(diff_text).decode("utf-8") | ||
except Exception: | ||
padding = 4 - (len(diff_text) % 4) | ||
if padding != 4: | ||
diff_text += "=" * padding | ||
diff_text = base64.b64decode(diff_text).decode("utf-8") | ||
|
||
logger.debug(f"Processing diff of length: {len(diff_text)}") | ||
description = await generate_pr_description(diff_text) | ||
|
||
with open(os.environ["GITHUB_OUTPUT"], "a") as f: | ||
f.write("content<<EOF\n") | ||
f.write(description) | ||
f.write("\nEOF\n") | ||
f.write(f"debug_diff_length={len(diff_text)}\n") | ||
f.write(f"debug_description_length={len(description)}\n") | ||
debug_preview = description[:500] | ||
f.write("debug_preview<<EOF\n") | ||
f.write(debug_preview) | ||
f.write("\nEOF\n") | ||
|
||
except Exception as e: | ||
logger.error(f"Error in main: {e}") | ||
raise | ||
|
||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Pre-commit Checks | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2 | ||
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b #v5.3.0 | ||
with: | ||
python-version: '3.11' | ||
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd #v3.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Update PR Description with Rigging | ||
|
||
on: | ||
pull_request: | ||
types: [opened] | ||
|
||
jobs: | ||
update-description: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
# Get the diff first | ||
- name: Get Diff | ||
id: diff | ||
run: | | ||
git fetch origin ${{ github.base_ref }} | ||
MERGE_BASE=$(git merge-base HEAD origin/${{ github.base_ref }}) | ||
# Encode the diff as base64 to preserve all characters | ||
DIFF=$(git diff $MERGE_BASE..HEAD | base64 -w 0) | ||
echo "diff=$DIFF" >> $GITHUB_OUTPUT | ||
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b #v5.0.3 | ||
with: | ||
python-version: "3.11" | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip cache purge | ||
pip install pydantic | ||
pip install rigging[all] | ||
# Generate the description using the diff | ||
- name: Generate PR Description | ||
id: description | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
GIT_DIFF: ${{ steps.diff.outputs.diff }} | ||
run: | | ||
python .github/scripts/rigging_pr_decorator.py | ||
# Update the PR description | ||
- name: Update PR Description | ||
uses: nefrob/pr-description@4dcc9f3ad5ec06b2a197c5f8f93db5e69d2fdca7 #v1.2.0 | ||
with: | ||
content: | | ||
## AI-Generated Summary | ||
${{ steps.description.outputs.content }} | ||
--- | ||
This summary was generated with ❤️ by [rigging](https://rigging.dreadnode.io/) | ||
regex: ".*" | ||
regexFlags: s | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.DS_Store | ||
logs/ | ||
.idea/workspace.xml | ||
.vscode/ | ||
.env | ||
archive/autogpt/.gradle/* | ||
archive/autogpt/.gradle/buildOutputCleanup/cache.properties | ||
.lock | ||
|
||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
|
||
# Ignore Gradle build output directory | ||
build | ||
|
||
# Ignore $py.class files (generated when running burp) | ||
|
||
.*$py.*class | ||
burpference/api_adapters$py.class | ||
burpference/consts$py.class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
repos: | ||
# Standard pre-commit hooks | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b #v5.0.0 | ||
hooks: | ||
- id: check-added-large-files | ||
args: [--maxkb=36000] | ||
- id: check-executables-have-shebangs | ||
- id: check-shebang-scripts-are-executable | ||
- id: check-json | ||
- id: check-yaml | ||
- id: trailing-whitespace | ||
|
||
# Github actions | ||
- repo: https://github.com/rhysd/actionlint | ||
rev: 5db9d9cde2f3deb5035dea3e45f0a9fff2f29448 #v1.7.4 | ||
hooks: | ||
- id: actionlint | ||
name: Check Github Actions | ||
|
||
# Secrets detection | ||
- repo: https://github.com/Yelp/detect-secrets | ||
rev: 01886c8a910c64595c47f186ca1ffc0b77fa5458 #v1.5.0 | ||
hooks: | ||
- id: detect-secrets | ||
name: Detect secrets | ||
args: | ||
- '--baseline' | ||
- '.secrets.baseline' | ||
- '--exclude-files' | ||
- 'components/api/migrations/*' | ||
- '--exclude-files' | ||
- 'components/api/app/assets/*' | ||
- '--exclude-files' | ||
- '\.sops\.yaml$' | ||
- '--exclude-files' | ||
- 'secrets\.enc\.yaml$' | ||
- '--exclude-files' | ||
- 'components/strikes/*' | ||
|
||
# Python linting | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: 8b76f04e7e5a9cd259e9d1db7799599355f97cdf # v0.8.2 | ||
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
# Run the formatter. | ||
- id: ruff-format | ||
|
||
# Python code security | ||
- repo: https://github.com/PyCQA/bandit | ||
rev: 8fd258abbac759d62863779f946d6a88e8eabb0f #1.8.0 | ||
hooks: | ||
- id: bandit | ||
name: Code security checks | ||
args: ["-c", "pyproject.toml"] | ||
additional_dependencies: ["bandit[toml]"] | ||
|
||
- repo: local | ||
hooks: | ||
# Ensure our GH actions are pinned to a specific hash | ||
- id: check-github-actions | ||
name: Check GitHub Actions for Pinned Dependencies | ||
entry: python .scripts/check_pinned_hash_dependencies.py | ||
language: python | ||
files: \.github/.*\.yml$ |
Oops, something went wrong.