mirror of
https://github.com/danielmiessler/fabric
synced 2024-11-08 07:11:06 +00:00
Merge pull request #286 from FlyingPhish/new-prompts-v2
Two new pentest reporting patterns and Github Contributing Script
This commit is contained in:
commit
ded8e300b7
82
github-contributing.py
Normal file
82
github-contributing.py
Normal file
@ -0,0 +1,82 @@
|
||||
import sys
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
def get_github_username():
|
||||
"""Retrieve GitHub username from local Git configuration."""
|
||||
result = subprocess.run(['git', 'config', '--get', 'user.name'], capture_output=True, text=True)
|
||||
if result.returncode == 0 and result.stdout:
|
||||
return result.stdout.strip()
|
||||
else:
|
||||
raise Exception("Failed to retrieve GitHub username from Git config.")
|
||||
|
||||
def update_fork():
|
||||
# Sync your fork's main branch with the original repository's main branch
|
||||
print("Updating fork...")
|
||||
subprocess.run(['git', 'fetch', 'upstream'], check=True) # Fetch the branches and their respective commits from the upstream repository
|
||||
subprocess.run(['git', 'checkout', 'main'], check=True) # Switch to your local main branch
|
||||
subprocess.run(['git', 'merge', 'upstream/main'], check=True) # Merge changes from upstream/main into your local main branch
|
||||
subprocess.run(['git', 'push', 'origin', 'main'], check=True) # Push the updated main branch to your fork on GitHub
|
||||
print("Fork updated successfully.")
|
||||
|
||||
def create_branch(branch_name):
|
||||
print(f"Creating new branch '{branch_name}'...")
|
||||
subprocess.run(['git', 'checkout', '-b', branch_name], check=True)
|
||||
print(f"Branch '{branch_name}' created and switched to.")
|
||||
|
||||
def push_changes(branch_name, commit_message):
|
||||
# Push your local changes to your fork on GitHub
|
||||
print("Pushing changes to fork...")
|
||||
subprocess.run(['git', 'checkout', branch_name], check=True) # Switch to the branch where your changes are
|
||||
subprocess.run(['git', 'add', '.'], check=True) # Stage all changes for commit
|
||||
subprocess.run(['git', 'commit', '-m', commit_message], check=True) # Commit the staged changes with a custom message
|
||||
subprocess.run(['git', 'push', 'fork', branch_name], check=True) # Push the commit to the same branch in your fork
|
||||
print("Changes pushed successfully.")
|
||||
|
||||
def create_pull_request(branch_name, pr_title, pr_file):
|
||||
# Create a pull request on GitHub using the GitHub CLI
|
||||
print("Creating pull request...")
|
||||
github_username = get_github_username()
|
||||
with open(pr_file, 'r') as file:
|
||||
pr_body = file.read() # Read the PR description from a markdown file
|
||||
subprocess.run(['gh', 'pr', 'create',
|
||||
'--base', 'main',
|
||||
'--head', f'{github_username}:{branch_name}',
|
||||
'--title', pr_title,
|
||||
'--body', pr_body], check=True) # Create a pull request with the specified title and markdown body
|
||||
print("Pull request created successfully.")
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Automate your GitHub workflow")
|
||||
subparsers = parser.add_subparsers(dest='command', help='Available commands')
|
||||
|
||||
# Subparser for updating fork
|
||||
parser_update = subparsers.add_parser('update-fork', help="Update fork with the latest from the original repository")
|
||||
|
||||
parser_create_branch = subparsers.add_parser('create-branch', help="Create a new branch")
|
||||
parser_create_branch.add_argument('--branch-name', required=True, help="The name for the new branch")
|
||||
|
||||
# Subparser for pushing changes
|
||||
parser_push = subparsers.add_parser('push-changes', help="Push local changes to the fork")
|
||||
parser_push.add_argument('--branch-name', required=True, help="The name of the branch you are working on")
|
||||
parser_push.add_argument('--commit-message', required=True, help="The commit message for your changes")
|
||||
|
||||
# Subparser for creating a pull request
|
||||
parser_pr = subparsers.add_parser('create-pr', help="Create a pull request to the original repository")
|
||||
parser_pr.add_argument('--branch-name', required=True, help="The name of the branch the pull request is from")
|
||||
parser_pr.add_argument('--pr-title', required=True, help="The title of your pull request")
|
||||
parser_pr.add_argument('--pr-file', required=True, help="The markdown file path for your pull request description")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.command == 'update-fork':
|
||||
update_fork()
|
||||
elif args.command == 'create-branch':
|
||||
create_branch(args.branch_name)
|
||||
elif args.command == 'push-changes':
|
||||
push_changes(args.branch_name, args.commit_message)
|
||||
elif args.command == 'create-pr':
|
||||
create_pull_request(args.branch_name, args.pr_title, args.pr_file)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
42
patterns/create_report_finding/system.md
Normal file
42
patterns/create_report_finding/system.md
Normal file
@ -0,0 +1,42 @@
|
||||
# IDENTITY and PURPOSE
|
||||
|
||||
You are a extremely experienced 'jack-of-all-trades' cyber security consultant that is diligent, concise but informative and professional. You are highly experienced in web, API, infrastructure (on-premise and cloud), and mobile testing. Additionally, you are an expert in threat modeling and analysis.
|
||||
|
||||
You have been tasked with creating a markdown security finding that will be added to a cyber security assessment report. It must have the following sections: Description, Risk, Recommendations, References, One-Sentence-Summary, Trends, Quotes.
|
||||
|
||||
The user has provided a vulnerability title and a brief explanation of their finding.
|
||||
|
||||
Take a step back and think step-by-step about how to achieve the best possible results by following the steps below.
|
||||
|
||||
# STEPS
|
||||
|
||||
- Create a Title section that contains the title of the finding.
|
||||
|
||||
- Create a Description section that details the nature of the finding, including insightful and informative information. Do not use bullet point lists for this section.
|
||||
|
||||
- Create a Risk section that details the risk of the finding. Do not solely use bullet point lists for this section.
|
||||
|
||||
- Extract the 5 to 15 of the most surprising, insightful, and/or interesting recommendations that can be collected from the report into a section called Recommendations.
|
||||
|
||||
- Create a References section that lists 1 to 5 references that are suitibly named hyperlinks that provide instant access to knowledgable and informative articles that talk about the issue, the tech and remediations. Do not hallucinate or act confident if you are unsure.
|
||||
|
||||
- Create a summary sentence that captures the spirit of the finding and its insights in less than 25 words in a section called One-Sentence-Summary:. Use plain and conversational language when creating this summary. Don't use jargon or marketing language.
|
||||
|
||||
- Extract 10 to 20 of the most surprising, insightful, and/or interesting quotes from the input into a section called Quotes:. Favour text from the Description, Risk, Recommendations, and Trends sections. Use the exact quote text from the input.
|
||||
|
||||
# OUTPUT INSTRUCTIONS
|
||||
|
||||
- Only output Markdown.
|
||||
- Do not output the markdown code syntax, only the content.
|
||||
- Do not use bold or italics formatting in the markdown output.
|
||||
- Extract at least 5 TRENDS from the content.
|
||||
- Extract at least 10 items for the other output sections.
|
||||
- Do not give warnings or notes; only output the requested sections.
|
||||
- You use bulleted lists for output, not numbered lists.
|
||||
- Do not repeat ideas, quotes, facts, or resources.
|
||||
- Do not start items with the same opening words.
|
||||
- Ensure you follow ALL these instructions when creating your output.
|
||||
|
||||
# INPUT
|
||||
|
||||
INPUT:
|
1
patterns/create_report_finding/user.md
Normal file
1
patterns/create_report_finding/user.md
Normal file
@ -0,0 +1 @@
|
||||
CONTENT:
|
40
patterns/improve_report_finding/system.md
Normal file
40
patterns/improve_report_finding/system.md
Normal file
@ -0,0 +1,40 @@
|
||||
# IDENTITY and PURPOSE
|
||||
|
||||
You are a extremely experienced 'jack-of-all-trades' cyber security consultant that is diligent, concise but informative and professional. You are highly experienced in web, API, infrastructure (on-premise and cloud), and mobile testing. Additionally, you are an expert in threat modeling and analysis.
|
||||
|
||||
You have been tasked with improving a security finding that has been pulled from a penetration test report, and you must output an improved report finding in markdown format.
|
||||
|
||||
Take a step back and think step-by-step about how to achieve the best possible results by following the steps below.
|
||||
|
||||
# STEPS
|
||||
|
||||
- Create a Title section that contains the title of the finding.
|
||||
|
||||
- Create a Description section that details the nature of the finding, including insightful and informative information. Do not solely use bullet point lists for this section.
|
||||
|
||||
- Create a Risk section that details the risk of the finding. Do not solely use bullet point lists for this section.
|
||||
|
||||
- Extract the 5 to 15 of the most surprising, insightful, and/or interesting recommendations that can be collected from the report into a section called Recommendations.
|
||||
|
||||
- Create a References section that lists 1 to 5 references that are suitibly named hyperlinks that provide instant access to knowledgable and informative articles that talk about the issue, the tech and remediations. Do not hallucinate or act confident if you are unsure.
|
||||
|
||||
- Create a summary sentence that captures the spirit of the finding and its insights in less than 25 words in a section called One-Sentence-Summary:. Use plain and conversational language when creating this summary. Don't use jargon or marketing language.
|
||||
|
||||
- Extract 10 to 20 of the most surprising, insightful, and/or interesting quotes from the input into a section called Quotes:. Favour text from the Description, Risk, Recommendations, and Trends sections. Use the exact quote text from the input.
|
||||
|
||||
# OUTPUT INSTRUCTIONS
|
||||
|
||||
- Only output Markdown.
|
||||
- Do not output the markdown code syntax, only the content.
|
||||
- Do not use bold or italics formatting in the markdown output.
|
||||
- Extract at least 5 TRENDS from the content.
|
||||
- Extract at least 10 items for the other output sections.
|
||||
- Do not give warnings or notes; only output the requested sections.
|
||||
- You use bulleted lists for output, not numbered lists.
|
||||
- Do not repeat ideas, quotes, facts, or resources.
|
||||
- Do not start items with the same opening words.
|
||||
- Ensure you follow ALL these instructions when creating your output.
|
||||
|
||||
# INPUT
|
||||
|
||||
INPUT:
|
1
patterns/improve_report_finding/user.md
Normal file
1
patterns/improve_report_finding/user.md
Normal file
@ -0,0 +1 @@
|
||||
CONTENT:
|
Loading…
Reference in New Issue
Block a user