From 9c89e0cf2bc863d481fe1897b7b75d93e37e016a Mon Sep 17 00:00:00 2001 From: FlyingPhishy Date: Thu, 21 Mar 2024 13:33:31 +0000 Subject: [PATCH 01/10] two new prompts, create and improve report finding for pentest repor finding generation. --- github-contributing.py | 63 +++++++++++++++++++++++ patterns/create_report_finding/system.md | 44 ++++++++++++++++ patterns/create_report_finding/user.md | 1 + patterns/improve_report_finding/system.md | 42 +++++++++++++++ patterns/improve_report_finding/user.md | 1 + 5 files changed, 151 insertions(+) create mode 100644 github-contributing.py create mode 100644 patterns/create_report_finding/system.md create mode 100644 patterns/create_report_finding/user.md create mode 100644 patterns/improve_report_finding/system.md create mode 100644 patterns/improve_report_finding/user.md diff --git a/github-contributing.py b/github-contributing.py new file mode 100644 index 0000000..a394a18 --- /dev/null +++ b/github-contributing.py @@ -0,0 +1,63 @@ +import sys +import argparse +import subprocess + +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 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', 'origin', branch_name], check=True) # Push the commit to the same branch in your fork + print("Changes pushed successfully.") + +def create_pull_request(pr_title, pr_file, branch_name): + # Create a pull request on GitHub using the GitHub CLI + print("Creating pull request...") + 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'{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") + + # 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 == '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() diff --git a/patterns/create_report_finding/system.md b/patterns/create_report_finding/system.md new file mode 100644 index 0000000..054b484 --- /dev/null +++ b/patterns/create_report_finding/system.md @@ -0,0 +1,44 @@ +# 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 up to 20 of the most surprising, insightful, and/or interesting trends from the input in a section called Trends:. If there are less than 50 then collect all of them. Make sure you extract at least 20. + +- 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: diff --git a/patterns/create_report_finding/user.md b/patterns/create_report_finding/user.md new file mode 100644 index 0000000..b8504b7 --- /dev/null +++ b/patterns/create_report_finding/user.md @@ -0,0 +1 @@ +CONTENT: diff --git a/patterns/improve_report_finding/system.md b/patterns/improve_report_finding/system.md new file mode 100644 index 0000000..c393b61 --- /dev/null +++ b/patterns/improve_report_finding/system.md @@ -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 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 up to 20 of the most surprising, insightful, and/or interesting trends from the input in a section called Trends:. If there are less than 50 then collect all of them. Make sure you extract at least 20. + +- 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: diff --git a/patterns/improve_report_finding/user.md b/patterns/improve_report_finding/user.md new file mode 100644 index 0000000..b8504b7 --- /dev/null +++ b/patterns/improve_report_finding/user.md @@ -0,0 +1 @@ +CONTENT: From d34831dbd6499df79cd9486690d980a559fcf53a Mon Sep 17 00:00:00 2001 From: FlyingPhishy Date: Thu, 21 Mar 2024 13:35:15 +0000 Subject: [PATCH 02/10] two new prompts, create and improve report finding for pentest repor finding generation. --- github-contributing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-contributing.py b/github-contributing.py index a394a18..3f68ccb 100644 --- a/github-contributing.py +++ b/github-contributing.py @@ -17,7 +17,7 @@ def push_changes(branch_name, commit_message): 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', 'origin', branch_name], check=True) # Push the commit to the same branch in your fork + 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(pr_title, pr_file, branch_name): From 11b373f49e30d9fc16c68ff54420a9adc21f8210 Mon Sep 17 00:00:00 2001 From: FlyingPhishy Date: Thu, 21 Mar 2024 13:48:33 +0000 Subject: [PATCH 03/10] added create_branch function to git-cont.py. --- github-contributing.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/github-contributing.py b/github-contributing.py index 3f68ccb..0d3eaa5 100644 --- a/github-contributing.py +++ b/github-contributing.py @@ -11,6 +11,11 @@ def update_fork(): 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...") @@ -54,6 +59,8 @@ def main(): 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': From 080138196ae197ec4a39d3de8caa6b15b7d45ef8 Mon Sep 17 00:00:00 2001 From: FlyingPhishy Date: Thu, 21 Mar 2024 14:05:18 +0000 Subject: [PATCH 04/10] last min changes --- .github/feature.md | 63 +++++++++++++++++++++++ patterns/create_report_finding/system.md | 2 - patterns/improve_report_finding/system.md | 2 - 3 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 .github/feature.md diff --git a/.github/feature.md b/.github/feature.md new file mode 100644 index 0000000..2d220e7 --- /dev/null +++ b/.github/feature.md @@ -0,0 +1,63 @@ +## What this Pull Request (PR) does +PR includes two new patterns: + +1) `create_report_finding` + * This takes either a file or text via echo for example and creates a pentest report finding that includes the following sections: + * title, description, risk, remedation, external references (please check these), one-sentence-summary, quotes. + * example usage: echo "Username Enumeration: Forgotten Password Functionality: The application returns if an account exists or not, which allows an attacker to enumerate valid user accounts via email address" | create_report_finding + +2) `improve_report_finding` + * This takes either a file or text via echo for example and creates an improved pentest report finding that includes the following sections: + * title, description, risk, remedation, external references (please check these), one-sentence-summary, quotes. + * example usage: cat sanitised_report_finding.txt (should have title, description, remediation sections) | improve_report_finding + +Additionally, this PR includes a Github helper script for automating the Github contributing workflow. This allows you to: + +1) Update your fork with the main repo to ensure you're working on a current version. +2) Create a new branch. +3) Push changes to your branch (or new branch). +4) Create a PR using a markdown file to populate the body. + +## Example Output from `create_report_finding`: +### Username Enumeration: Forgotten Password Functionality + +#### Description +The application in question has a security flaw within its forgotten password functionality. Specifically, when a user attempts to reset their password using an email address, the application responds differently depending on whether the email address is associated with an existing account. This behavior inadvertently provides attackers with a means to confirm the existence of valid user accounts. By systematically submitting various email addresses through this functionality, an attacker can compile a list of valid accounts for further malicious activities, such as targeted phishing attacks or brute force password attempts. + +#### Risk +This vulnerability poses a significant risk as it directly compromises user privacy and security. The ability for an attacker to enumerate valid user accounts elevates the risk of targeted attacks. Users with identified accounts may become victims of phishing campaigns designed to extract more sensitive information or deceive them into compromising their account security. Furthermore, knowing which accounts are valid can aid an attacker in focusing their efforts on existing accounts when attempting password breaches, making the attack more efficient and likely to succeed. + +#### Recommendations +- Implement a uniform response message for all password reset attempts, regardless of whether the email address is associated with an existing account or not. +- Employ CAPTCHA mechanisms to prevent automated scripts from performing mass enumeration attempts. +- Rate limit the number of password reset requests that can be made from a single IP address within a given timeframe to deter enumeration attacks. +- Monitor and log all password reset attempts to detect and respond to potential enumeration activities. +- Educate users on the importance of using unique, strong passwords for their accounts to mitigate the risk of unauthorized access should their email address be enumerated. +- Consider implementing multi-factor authentication (MFA) as an additional layer of security for account access, reducing the impact of account enumeration. + +#### References +- [OWASP Guide to Authentication](https://owasp.org/www-project-cheat-sheets/cheatsheets/Authentication_Cheat_Sheet.html) +- [NIST Recommendations on Digital Identity Guidelines](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-63b.pdf) +- [CWE-203: Information Exposure Through Discrepancy](https://cwe.mitre.org/data/definitions/203.html) + +#### One-Sentence-Summary: +The forgotten password functionality reveals if an email is linked to an account, enabling attackers to identify valid user accounts. + +#### Trends: +- Increasing sophistication of automated scripts used by attackers for account enumeration. +- Growing awareness and adoption of multi-factor authentication (MFA) as a countermeasure. +- Enhanced focus on privacy regulations prompting better security practices around user data. +- Rise in targeted phishing attacks leveraging enumerated account information. +- Shift towards uniform error responses across web applications to mitigate enumeration risks. + +#### Quotes: +- "The application responds differently depending on whether the email address is associated with an existing account." +- "This behavior inadvertently provides attackers with a means to confirm the existence of valid user accounts." +- "Users with identified accounts may become victims of phishing campaigns." +- "Knowing which accounts are valid can aid an attacker in focusing their efforts." +- "Implement a uniform response message for all password reset attempts." +- "Employ CAPTCHA mechanisms to prevent automated scripts." +- "Rate limit the number of password reset requests from a single IP address." +- "Educate users on the importance of using unique, strong passwords." +- "Consider implementing multi-factor authentication (MFA) as an additional layer of security." +- "Increasing sophistication of automated scripts used by attackers for account enumeration."% diff --git a/patterns/create_report_finding/system.md b/patterns/create_report_finding/system.md index 054b484..5ba0a38 100644 --- a/patterns/create_report_finding/system.md +++ b/patterns/create_report_finding/system.md @@ -22,8 +22,6 @@ Take a step back and think step-by-step about how to achieve the best possible r - 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 up to 20 of the most surprising, insightful, and/or interesting trends from the input in a section called Trends:. If there are less than 50 then collect all of them. Make sure you extract at least 20. - - 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 diff --git a/patterns/improve_report_finding/system.md b/patterns/improve_report_finding/system.md index c393b61..597ff9e 100644 --- a/patterns/improve_report_finding/system.md +++ b/patterns/improve_report_finding/system.md @@ -20,8 +20,6 @@ Take a step back and think step-by-step about how to achieve the best possible r - 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 up to 20 of the most surprising, insightful, and/or interesting trends from the input in a section called Trends:. If there are less than 50 then collect all of them. Make sure you extract at least 20. - - 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 From 27d620f7c1803d52058893ffdd7fa3c3f5984786 Mon Sep 17 00:00:00 2001 From: FlyingPhishy Date: Thu, 21 Mar 2024 14:06:43 +0000 Subject: [PATCH 05/10] last min changes --- .github/pull_request_template.md | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 90e8adc..0000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,9 +0,0 @@ -## What this Pull Request (PR) does -Please briefly describe what this PR does. - -## Related issues -Please reference any open issues this PR relates to in here. -If it closes an issue, type `closes #[ISSUE_NUMBER]`. - -## Screenshots -Provide any screenshots you may find relevant to facilitate us understanding your PR. From 3f202f4d53e14be7cb313ce13b2b88dfdfe8c237 Mon Sep 17 00:00:00 2001 From: FlyingPhishy Date: Thu, 21 Mar 2024 14:07:17 +0000 Subject: [PATCH 06/10] last min changes --- .github/feature.md | 63 -------------------------------- .github/pull_request_template.md | 9 +++++ 2 files changed, 9 insertions(+), 63 deletions(-) delete mode 100644 .github/feature.md create mode 100644 .github/pull_request_template.md diff --git a/.github/feature.md b/.github/feature.md deleted file mode 100644 index 2d220e7..0000000 --- a/.github/feature.md +++ /dev/null @@ -1,63 +0,0 @@ -## What this Pull Request (PR) does -PR includes two new patterns: - -1) `create_report_finding` - * This takes either a file or text via echo for example and creates a pentest report finding that includes the following sections: - * title, description, risk, remedation, external references (please check these), one-sentence-summary, quotes. - * example usage: echo "Username Enumeration: Forgotten Password Functionality: The application returns if an account exists or not, which allows an attacker to enumerate valid user accounts via email address" | create_report_finding - -2) `improve_report_finding` - * This takes either a file or text via echo for example and creates an improved pentest report finding that includes the following sections: - * title, description, risk, remedation, external references (please check these), one-sentence-summary, quotes. - * example usage: cat sanitised_report_finding.txt (should have title, description, remediation sections) | improve_report_finding - -Additionally, this PR includes a Github helper script for automating the Github contributing workflow. This allows you to: - -1) Update your fork with the main repo to ensure you're working on a current version. -2) Create a new branch. -3) Push changes to your branch (or new branch). -4) Create a PR using a markdown file to populate the body. - -## Example Output from `create_report_finding`: -### Username Enumeration: Forgotten Password Functionality - -#### Description -The application in question has a security flaw within its forgotten password functionality. Specifically, when a user attempts to reset their password using an email address, the application responds differently depending on whether the email address is associated with an existing account. This behavior inadvertently provides attackers with a means to confirm the existence of valid user accounts. By systematically submitting various email addresses through this functionality, an attacker can compile a list of valid accounts for further malicious activities, such as targeted phishing attacks or brute force password attempts. - -#### Risk -This vulnerability poses a significant risk as it directly compromises user privacy and security. The ability for an attacker to enumerate valid user accounts elevates the risk of targeted attacks. Users with identified accounts may become victims of phishing campaigns designed to extract more sensitive information or deceive them into compromising their account security. Furthermore, knowing which accounts are valid can aid an attacker in focusing their efforts on existing accounts when attempting password breaches, making the attack more efficient and likely to succeed. - -#### Recommendations -- Implement a uniform response message for all password reset attempts, regardless of whether the email address is associated with an existing account or not. -- Employ CAPTCHA mechanisms to prevent automated scripts from performing mass enumeration attempts. -- Rate limit the number of password reset requests that can be made from a single IP address within a given timeframe to deter enumeration attacks. -- Monitor and log all password reset attempts to detect and respond to potential enumeration activities. -- Educate users on the importance of using unique, strong passwords for their accounts to mitigate the risk of unauthorized access should their email address be enumerated. -- Consider implementing multi-factor authentication (MFA) as an additional layer of security for account access, reducing the impact of account enumeration. - -#### References -- [OWASP Guide to Authentication](https://owasp.org/www-project-cheat-sheets/cheatsheets/Authentication_Cheat_Sheet.html) -- [NIST Recommendations on Digital Identity Guidelines](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-63b.pdf) -- [CWE-203: Information Exposure Through Discrepancy](https://cwe.mitre.org/data/definitions/203.html) - -#### One-Sentence-Summary: -The forgotten password functionality reveals if an email is linked to an account, enabling attackers to identify valid user accounts. - -#### Trends: -- Increasing sophistication of automated scripts used by attackers for account enumeration. -- Growing awareness and adoption of multi-factor authentication (MFA) as a countermeasure. -- Enhanced focus on privacy regulations prompting better security practices around user data. -- Rise in targeted phishing attacks leveraging enumerated account information. -- Shift towards uniform error responses across web applications to mitigate enumeration risks. - -#### Quotes: -- "The application responds differently depending on whether the email address is associated with an existing account." -- "This behavior inadvertently provides attackers with a means to confirm the existence of valid user accounts." -- "Users with identified accounts may become victims of phishing campaigns." -- "Knowing which accounts are valid can aid an attacker in focusing their efforts." -- "Implement a uniform response message for all password reset attempts." -- "Employ CAPTCHA mechanisms to prevent automated scripts." -- "Rate limit the number of password reset requests from a single IP address." -- "Educate users on the importance of using unique, strong passwords." -- "Consider implementing multi-factor authentication (MFA) as an additional layer of security." -- "Increasing sophistication of automated scripts used by attackers for account enumeration."% diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..90e8adc --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,9 @@ +## What this Pull Request (PR) does +Please briefly describe what this PR does. + +## Related issues +Please reference any open issues this PR relates to in here. +If it closes an issue, type `closes #[ISSUE_NUMBER]`. + +## Screenshots +Provide any screenshots you may find relevant to facilitate us understanding your PR. From 82e3c0a521549cbf25246427d33e0fe865b38cc6 Mon Sep 17 00:00:00 2001 From: FlyingPhishy Date: Thu, 21 Mar 2024 14:11:50 +0000 Subject: [PATCH 07/10] last min fixes --- github-contributing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-contributing.py b/github-contributing.py index 0d3eaa5..b73328c 100644 --- a/github-contributing.py +++ b/github-contributing.py @@ -15,7 +15,7 @@ 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...") From be785277072ec0aa23247b7c5143b74bd9c7dc5b Mon Sep 17 00:00:00 2001 From: FlyingPhishy Date: Thu, 21 Mar 2024 14:13:07 +0000 Subject: [PATCH 08/10] last min fixes --- github-contributing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-contributing.py b/github-contributing.py index b73328c..4ec3c51 100644 --- a/github-contributing.py +++ b/github-contributing.py @@ -25,7 +25,7 @@ def push_changes(branch_name, commit_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(pr_title, pr_file, branch_name): +def create_pull_request(branch_name, pr_title, pr_file): # Create a pull request on GitHub using the GitHub CLI print("Creating pull request...") with open(pr_file, 'r') as file: From 7338411a7d52cd2304138c44373c94258706efa1 Mon Sep 17 00:00:00 2001 From: FlyingPhishy Date: Thu, 21 Mar 2024 14:20:37 +0000 Subject: [PATCH 09/10] unfucking things --- github-contributing.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/github-contributing.py b/github-contributing.py index 4ec3c51..074b24d 100644 --- a/github-contributing.py +++ b/github-contributing.py @@ -44,6 +44,9 @@ def main(): # 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") From 4a753ab0e11e10a45926ae25b2400c1da5a4a3ae Mon Sep 17 00:00:00 2001 From: FlyingPhish Date: Thu, 21 Mar 2024 14:27:44 +0000 Subject: [PATCH 10/10] unfucking things --- github-contributing.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/github-contributing.py b/github-contributing.py index 074b24d..1d26c60 100644 --- a/github-contributing.py +++ b/github-contributing.py @@ -2,6 +2,14 @@ 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...") @@ -28,11 +36,12 @@ def push_changes(branch_name, commit_message): 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'{branch_name}', + '--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.")