Skip to content

Commit 7e81641

Browse files
chore: init commit new repo
0 parents  commit 7e81641

26 files changed

+1915
-0
lines changed

.github/ISSUE_TEMPLATE.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## Issue
2+
3+
### Description
4+
5+
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.
6+
7+
### Steps to Reproduce (for bug reports)
8+
9+
1. Go to '...'
10+
2. Click on '...'
11+
3. Scroll down to '...'
12+
4. See error
13+
14+
### Expected Behavior
15+
16+
A clear and concise description of what you expected to happen.
17+
18+
### Screenshots
19+
20+
If applicable, add screenshots to help explain your problem.
21+
22+
### Environment
23+
24+
- OS: [e.g., Windows, macOS, Linux]
25+
- Burp Suite Version: [e.g., 2023.1]
26+
- Jython Version: [e.g., 2.7.4]
27+
- Other relevant environment details
28+
29+
### Additional Context
30+
31+
Add any other context about the problem here.
32+
33+
### Feature Request
34+
35+
If you are requesting a new feature, please describe the feature in detail and provide any relevant examples or use cases.
36+
37+
### Contribution
38+
39+
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.

.github/PULL_REQUEST_TEMPLATE.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
🏴‍☠️ Burpference
2+
3+
## Ahoy, Mateys!
4+
5+
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!
+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
import asyncio
2+
import base64
3+
import os
4+
import typing as t
5+
6+
from pydantic import ConfigDict, StringConstraints
7+
8+
import rigging as rg
9+
from rigging import logger
10+
from rigging.generator import GenerateParams, Generator, register_generator
11+
12+
logger.enable("rigging")
13+
14+
MAX_TOKENS = 8000
15+
TRUNCATION_WARNING = "\n\n**Note**: Due to the large size of this diff, some content has been truncated."
16+
str_strip = t.Annotated[str, StringConstraints(strip_whitespace=True)]
17+
18+
19+
class PRDiffData(rg.Model):
20+
"""XML model for PR diff data"""
21+
22+
content: str_strip = rg.element()
23+
24+
@classmethod
25+
def xml_example(cls) -> str:
26+
return """<diff><content>example diff content</content></diff>"""
27+
28+
29+
class PRDecorator(Generator):
30+
"""Generator for creating PR descriptions"""
31+
32+
model_config = ConfigDict(arbitrary_types_allowed=True, validate_assignment=True)
33+
34+
api_key: str = ""
35+
max_tokens: int = MAX_TOKENS
36+
37+
def __init__(self, model: str, params: rg.GenerateParams) -> None:
38+
api_key = params.extra.get("api_key")
39+
if not api_key:
40+
raise ValueError("api_key is required in params.extra")
41+
42+
super().__init__(model=model, params=params, api_key=api_key)
43+
self.api_key = api_key
44+
self.max_tokens = params.max_tokens or MAX_TOKENS
45+
46+
async def generate_messages(
47+
self,
48+
messages: t.Sequence[t.Sequence[rg.Message]],
49+
params: t.Sequence[GenerateParams],
50+
) -> t.Sequence[rg.GeneratedMessage]:
51+
responses = []
52+
for message_seq, p in zip(messages, params):
53+
base_generator = rg.get_generator(self.model, params=p)
54+
llm_response = await base_generator.generate_messages([message_seq], [p])
55+
responses.extend(llm_response)
56+
return responses
57+
58+
59+
register_generator("pr_decorator", PRDecorator)
60+
61+
62+
async def generate_pr_description(diff_text: str) -> str:
63+
"""Generate a PR description from the diff text"""
64+
diff_tokens = len(diff_text) // 4
65+
if diff_tokens >= MAX_TOKENS:
66+
char_limit = (MAX_TOKENS * 4) - len(TRUNCATION_WARNING)
67+
diff_text = diff_text[:char_limit] + TRUNCATION_WARNING
68+
69+
diff_data = PRDiffData(content=diff_text)
70+
params = rg.GenerateParams(
71+
extra={
72+
"api_key": os.environ["OPENAI_API_KEY"],
73+
"diff_text": diff_text,
74+
},
75+
temperature=0.1,
76+
max_tokens=500,
77+
)
78+
79+
generator = rg.get_generator("pr_decorator!gpt-4-turbo-preview", params=params)
80+
prompt = f"""You are a helpful AI that generates clear and concise PR descriptions with some pirate tongue.
81+
Analyze the provided git diff and create a summary, specifically focusing on the elements of the code that
82+
has changed, high severity functions etc using exactly this format:
83+
84+
### PR Summary
85+
86+
#### Overview of Changes
87+
<overview paragraph>
88+
89+
#### Key Modifications
90+
1. **<modification title>**: <description>
91+
(continue as needed)
92+
93+
#### Potential Impact
94+
- <impact point 1>
95+
(continue as needed)
96+
97+
Here is the PR diff to analyze:
98+
{diff_data.to_xml()}"""
99+
100+
chat = await generator.chat(prompt).run()
101+
return chat.last.content.strip()
102+
103+
104+
async def main():
105+
"""Main function for CI environment"""
106+
if not os.environ.get("OPENAI_API_KEY"):
107+
raise ValueError("OPENAI_API_KEY environment variable must be set")
108+
109+
try:
110+
diff_text = os.environ.get("GIT_DIFF", "")
111+
if not diff_text:
112+
raise ValueError("No diff found in GIT_DIFF environment variable")
113+
114+
try:
115+
diff_text = base64.b64decode(diff_text).decode("utf-8")
116+
except Exception:
117+
padding = 4 - (len(diff_text) % 4)
118+
if padding != 4:
119+
diff_text += "=" * padding
120+
diff_text = base64.b64decode(diff_text).decode("utf-8")
121+
122+
logger.debug(f"Processing diff of length: {len(diff_text)}")
123+
description = await generate_pr_description(diff_text)
124+
125+
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
126+
f.write("content<<EOF\n")
127+
f.write(description)
128+
f.write("\nEOF\n")
129+
f.write(f"debug_diff_length={len(diff_text)}\n")
130+
f.write(f"debug_description_length={len(description)}\n")
131+
debug_preview = description[:500]
132+
f.write("debug_preview<<EOF\n")
133+
f.write(debug_preview)
134+
f.write("\nEOF\n")
135+
136+
except Exception as e:
137+
logger.error(f"Error in main: {e}")
138+
raise
139+
140+
141+
if __name__ == "__main__":
142+
asyncio.run(main())

.github/workflows/pre-commit.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Pre-commit Checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
13+
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b #v5.3.0
14+
with:
15+
python-version: '3.11'
16+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd #v3.0.1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Update PR Description with Rigging
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
7+
jobs:
8+
update-description:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
pull-requests: write
12+
contents: read
13+
14+
steps:
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2
16+
with:
17+
fetch-depth: 0
18+
19+
# Get the diff first
20+
- name: Get Diff
21+
id: diff
22+
run: |
23+
git fetch origin ${{ github.base_ref }}
24+
MERGE_BASE=$(git merge-base HEAD origin/${{ github.base_ref }})
25+
# Encode the diff as base64 to preserve all characters
26+
DIFF=$(git diff $MERGE_BASE..HEAD | base64 -w 0)
27+
echo "diff=$DIFF" >> $GITHUB_OUTPUT
28+
- uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b #v5.0.3
29+
with:
30+
python-version: "3.11"
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip cache purge
36+
pip install pydantic
37+
pip install rigging[all]
38+
# Generate the description using the diff
39+
- name: Generate PR Description
40+
id: description
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
44+
PR_NUMBER: ${{ github.event.pull_request.number }}
45+
GIT_DIFF: ${{ steps.diff.outputs.diff }}
46+
run: |
47+
python .github/scripts/rigging_pr_decorator.py
48+
# Update the PR description
49+
- name: Update PR Description
50+
uses: nefrob/pr-description@4dcc9f3ad5ec06b2a197c5f8f93db5e69d2fdca7 #v1.2.0
51+
with:
52+
content: |
53+
## AI-Generated Summary
54+
${{ steps.description.outputs.content }}
55+
---
56+
This summary was generated with ❤️ by [rigging](https://rigging.dreadnode.io/)
57+
regex: ".*"
58+
regexFlags: s
59+
token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.DS_Store
2+
logs/
3+
.idea/workspace.xml
4+
.vscode/
5+
.env
6+
archive/autogpt/.gradle/*
7+
archive/autogpt/.gradle/buildOutputCleanup/cache.properties
8+
.lock
9+
10+
# Ignore Gradle project-specific cache directory
11+
.gradle
12+
13+
# Ignore Gradle build output directory
14+
build
15+
16+
# Ignore $py.class files (generated when running burp)
17+
18+
.*$py.*class
19+
burpference/api_adapters$py.class
20+
burpference/consts$py.class

.pre-commit-config.yaml

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
repos:
2+
# Standard pre-commit hooks
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b #v5.0.0
5+
hooks:
6+
- id: check-added-large-files
7+
args: [--maxkb=36000]
8+
- id: check-executables-have-shebangs
9+
- id: check-shebang-scripts-are-executable
10+
- id: check-json
11+
- id: check-yaml
12+
- id: trailing-whitespace
13+
14+
# Github actions
15+
- repo: https://github.com/rhysd/actionlint
16+
rev: 5db9d9cde2f3deb5035dea3e45f0a9fff2f29448 #v1.7.4
17+
hooks:
18+
- id: actionlint
19+
name: Check Github Actions
20+
21+
# Secrets detection
22+
- repo: https://github.com/Yelp/detect-secrets
23+
rev: 01886c8a910c64595c47f186ca1ffc0b77fa5458 #v1.5.0
24+
hooks:
25+
- id: detect-secrets
26+
name: Detect secrets
27+
args:
28+
- '--baseline'
29+
- '.secrets.baseline'
30+
- '--exclude-files'
31+
- 'components/api/migrations/*'
32+
- '--exclude-files'
33+
- 'components/api/app/assets/*'
34+
- '--exclude-files'
35+
- '\.sops\.yaml$'
36+
- '--exclude-files'
37+
- 'secrets\.enc\.yaml$'
38+
- '--exclude-files'
39+
- 'components/strikes/*'
40+
41+
# Python linting
42+
- repo: https://github.com/astral-sh/ruff-pre-commit
43+
# Ruff version.
44+
rev: 8b76f04e7e5a9cd259e9d1db7799599355f97cdf # v0.8.2
45+
hooks:
46+
# Run the linter.
47+
- id: ruff
48+
# Run the formatter.
49+
- id: ruff-format
50+
51+
# Python code security
52+
- repo: https://github.com/PyCQA/bandit
53+
rev: 8fd258abbac759d62863779f946d6a88e8eabb0f #1.8.0
54+
hooks:
55+
- id: bandit
56+
name: Code security checks
57+
args: ["-c", "pyproject.toml"]
58+
additional_dependencies: ["bandit[toml]"]
59+
60+
- repo: local
61+
hooks:
62+
# Ensure our GH actions are pinned to a specific hash
63+
- id: check-github-actions
64+
name: Check GitHub Actions for Pinned Dependencies
65+
entry: python .scripts/check_pinned_hash_dependencies.py
66+
language: python
67+
files: \.github/.*\.yml$

0 commit comments

Comments
 (0)