-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored main branch #1
base: main
Are you sure you want to change the base?
Conversation
|
||
if args.runTeams and args.teamsToken == '': | ||
print("[!] Teams Bearer Token required for Teams enumeration, Exiting...") | ||
sys.exit() | ||
|
||
if args.teamsLegacy and args.outputfile == '': | ||
print("[!] Teams Legacy Output requires the output file option (-o). Exiting...") | ||
sys.exit() | ||
|
||
inputNames = [] | ||
nameList = [] | ||
validNames = [] | ||
legacyNames = [] | ||
|
||
for name in args.inputList.readlines(): | ||
inputNames.append(name) | ||
inputNames = list(args.inputList.readlines()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 32-47
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Replace identity comprehension with call to collection constructor (
identity-comprehension
) - Convert for loop into list comprehension (
list-comprehension
)
print("[V] " + str(e)) | ||
print(f"[V] {str(e)}") | ||
sys.exit() | ||
|
||
if args.verboseMode: | ||
print("[V] Using target tenant %s" % targetTenant) | ||
print(f"[V] Using target tenant {targetTenant}") | ||
|
||
for potentialUser in nameList: | ||
try: | ||
testURL = "https://" + targetTenant + "-my.sharepoint.com/personal/" + str(potentialUser.replace(".","_")) + "_" + str(args.targetDomain.replace(".","_")) + "/_layouts/15/onedrive.aspx" | ||
testURL = ( | ||
f"https://{targetTenant}-my.sharepoint.com/personal/" | ||
+ str(potentialUser.replace(".", "_")) | ||
+ "_" | ||
+ str(args.targetDomain.replace(".", "_")) | ||
+ "/_layouts/15/onedrive.aspx" | ||
) | ||
if args.verboseMode: | ||
print("[V] Testing: " + str(testURL)) | ||
print(f"[V] Testing: {str(testURL)}") | ||
userRequest = requests.get(testURL, verify=False) | ||
if userRequest.status_code in [200, 401, 403, 302]: | ||
print("[+] " + str(str(potentialUser) + "@" + str(args.targetDomain))) | ||
if userRequest.status_code in {200, 401, 403, 302}: | ||
print(f'[+] {str(f"{str(potentialUser)}@{str(args.targetDomain)}")}') | ||
validNames.append(str(potentialUser)) | ||
else: | ||
if args.verboseMode: | ||
print("[-] " + str(str(potentialUser) + "@" + str(args.targetDomain))) | ||
pass | ||
|
||
elif args.verboseMode: | ||
print(f'[-] {str(f"{str(potentialUser)}@{str(args.targetDomain)}")}') | ||
except Exception as e: | ||
if args.verboseMode: | ||
print("[V] " + str(e)) | ||
pass | ||
print(f"[V] {str(e)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function OneDriveEnumerator
refactored with the following changes:
- Use f-string instead of string concatenation [×11] (
use-fstring-for-concatenation
) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif
) - Use set when checking membership of a collection of literals (
collection-into-set
) - Remove redundant pass statement [×2] (
remove-redundant-pass
)
print("[V] Testing user %s" % potentialUserNameTeams) | ||
print(f"[V] Testing user {potentialUserNameTeams}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function teamsEnum
refactored with the following changes:
- Replace interpolated string formatting with f-string [×4] (
replace-interpolation-with-fstring
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Remove unnecessary casts to int, str, float or bool [×2] (
remove-unnecessary-cast
) - Use named expression to simplify assignment and conditional (
use-named-expression
) - Remove redundant conditional (
remove-redundant-if
) - Merge else clause's nested if statement into elif (
merge-else-if-into-elif
)
global nameList | ||
global nameList | ||
for name in inputNames: | ||
if "@" in name: | ||
name = name.split("@")[0] | ||
nameList.append(name.strip()) | ||
else: | ||
nameList.append(name.strip()) | ||
nameList.append(name.strip()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function main
refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if
) - Hoist a repeated condition into a parent condition (
hoist-repeated-if-condition
) - Remove redundant conditional [×2] (
remove-redundant-if
) - Swap positions of nested conditionals [×8] (
swap-nested-ifs
) - Hoist nested repeated code outside conditional statements [×8] (
hoist-similar-statement-from-if
) - Use f-string instead of string concatenation [×7] (
use-fstring-for-concatenation
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
Branch
main
refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
main
branch, then run:Help us improve this pull request!