Skip to content
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 master branch #4

Merged
merged 1 commit into from
Jan 8, 2024
Merged

Sourcery refactored master branch #4

merged 1 commit into from
Jan 8, 2024

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jan 8, 2024

Branch master 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 master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from daedalus January 8, 2024 22:06
Comment on lines -18 to +23
while turn == process and interested[other] == True:
while turn == turn and interested[other] == True:
k += 1
# if (k % 10000 == 0):
# print "process wait",process
continue
print("entered_critical: %d ticks %d" % (process, k))
print("entered_critical: %d ticks %d" % (turn, k))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function enter_region refactored with the following changes:

print("recv:" + ssl_sock.recv(512))
print(f"recv:{ssl_sock.recv(512)}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 33-33 refactored with the following changes:

i = list(difflib.unified_diff(s1, s2))

if len(i) > 0:
if i := list(difflib.unified_diff(s1, s2)):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 34-36 refactored with the following changes:

os.system("cat %s | gpg --decrypt > %s" % (sys.argv[1], tmp))
os.system(f"cat {sys.argv[1]} | gpg --decrypt > {tmp}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 15-25 refactored with the following changes:

Comment on lines -36 to +39
assert path.isfile(header_file), "Input file '%s' not found." % header_file
assert path.isfile(encrypted_partition), (
"Input file '%s' not found." % encrypted_partition
)
assert path.isfile(header_file), f"Input file '{header_file}' not found."
assert path.isfile(
encrypted_partition
), f"Input file '{encrypted_partition}' not found."
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 36-55 refactored with the following changes:

ftp.storlines("STOR %s" % filename, open(filename, "r"))
ftp.storlines(f"STOR {filename}", open(filename, "r"))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function upload refactored with the following changes:

a.append("sha3_256")
a.append("sha3_512")
a.extend(("sha3_256", "sha3_512"))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 10-11 refactored with the following changes:

Comment on lines -21 to +32
if l > 4:
url = (
url_base
+ "pasadas/"
+ str(codigo_parada)
+ "/"
+ tipo_dia
+ "/"
+ str(linea)
+ "/"
+ hora
)
else:
url = url_base + "pasadas/" + str(codigo_parada) + "/" + tipo_dia + "/" + hora

url = (
f"{url_base}pasadas/{str(codigo_parada)}/{tipo_dia}/{str(linea)}/{hora}"
if l > 4
else f"{url_base}pasadas/{str(codigo_parada)}/{tipo_dia}/{hora}"
)
j = json.loads(urllib.request.urlopen(url).read())
for pasada in j:
print(
"Linea:",
pasada["linea"],
"Hora:",
str(pasada["horaDesc"]),
pasada["horaDesc"],
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 21-42 refactored with the following changes:

for i in range(0, 365):
for _ in range(0, 365):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function calculate_best_candidate refactored with the following changes:

tmp = [x for x in range(1024 * 1024 * 20)]
tmp = list(range(1024 * 1024 * 20))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test refactored with the following changes:

Comment on lines -47 to +62
lru.insert("key" + str(i), str(i))
lru.insert(f"key{str(i)}", str(i))

for i in range(0, 1000):
for _ in range(0, 1000):
lru.get("key13")
for i in range(0, 500):
for _ in range(0, 500):
lru.get("key11")
for i in range(0, 250):
for _ in range(0, 250):
lru.get("key7")
for i in range(0, 125):
for _ in range(0, 125):
lru.get("key5")
lru.get("key3")
lru.get("key2")
lru.get("key1")

print(lru.access)
for i in range(0, 3):
for _ in range(0, 3):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test refactored with the following changes:

for line in maps_file.readlines():
for line in maps_file:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 11-11 refactored with the following changes:

Comment on lines -30 to -45
if opt == "-n":
remote_hosts = list(ipaddress.IPv4Network(str(sys.argv[2]), strict=False).hosts())

if opt == "-f":
remote_hosts = []
fp = open(sys.argv[2], "r")
for line in fp:
if line.find("#") == -1:
remote_hosts.append(line.strip())
remote_hosts = [line.strip() for line in fp if line.find("#") == -1]
elif opt == "-n":
remote_hosts = list(ipaddress.IPv4Network(str(sys.argv[2]), strict=False).hosts())

for remote_host in remote_hosts:
if no_ping:
if not no_ping and pyping.ping(str(remote_host)) or no_ping:
print(payload % (exploit, remote_host, local_host, local_port, meterpreter))
else:
if pyping.ping(str(remote_host)):
print(payload % (exploit, remote_host, local_host, local_port, meterpreter))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 30-45 refactored with the following changes:

data = get_json(fp, line.replace("\n", ""))
if data:
if data := get_json(fp, line.replace("\n", "")):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 31-32 refactored with the following changes:

Comment on lines -14 to +30
print("Required hash: %s" % REQ)
print(f"Required hash: {REQ}")
apmac = "34:bf:90:4a:bb:57"
clmac = "98:de:d0:1a:97:c2"
PSK = "786 5555"
SSID = "unknown"

print("SSID: [%s]" % SSID)
print("PSK: [%s]" % PSK)
print("AP mac: %s" % apmac)
print("Cl mac: %s" % clmac)
print(f"SSID: [{SSID}]")
print(f"PSK: [{PSK}]")
print(f"AP mac: {apmac}")
print(f"Cl mac: {clmac}")
print(
"HASH: %s*%s*%s*%s"
% (
REQ,
apmac.replace(":", ""),
clmac.replace(":", ""),
binascii.hexlify(SSID),
)
f'HASH: {REQ}*{apmac.replace(":", "")}*{clmac.replace(":", "")}*{binascii.hexlify(SSID)}'
)

pmkid, pmk = PMKID(apmac, clmac, PSK, SSID)
print("PMK: " + binascii.hexlify(pmk))
print("PMKID: " + binascii.hexlify(pmkid[0:32]))
print(f"PMK: {binascii.hexlify(pmk)}")
print(f"PMKID: {binascii.hexlify(pmkid[:32])}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 14-36 refactored with the following changes:

if binascii.hexlify(sha256(dec)) == sha256_payload_check:
return dec
else:
return False
return dec if binascii.hexlify(sha256(dec)) == sha256_payload_check else False
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test2 refactored with the following changes:

"Plaintext_decoded: '%s'"
% binascii.unhexlify(hex(message).replace("0x", "").replace("L", "").zfill(b))
f"""Plaintext_decoded: '{binascii.unhexlify(hex(message).replace("0x", "").replace("L", "").zfill(b))}'"""
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test refactored with the following changes:

Comment on lines -48 to +58
for i in range(0, 1000000):
for _ in range(0, 1000000):
tmp = math.sqrt(n)
t1 = time.time() - t0
print(t1)
t0 = time.time()
for i in range(0, 1000000):
for _ in range(0, 1000000):
tmp = math.pow(n, -0.5)
t1 = time.time() - t0
print(t1)
t0 = time.time()
for i in range(0, 1000000):
for _ in range(0, 1000000):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function benchmark refactored with the following changes:

Comment on lines -11 to +18
if n > 0:
tmp = []
for dataset in data:
a, b = split(dataset)
tmp += [a] + [b]
print(tmp)
return partition(n - 1, tmp)
else:
if n <= 0:
return data
tmp = []
for dataset in data:
a, b = split(dataset)
tmp += [a] + [b]
print(tmp)
return partition(n - 1, tmp)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function partition refactored with the following changes:

url = "https://xchain.io/api/balances/%s" % addr
url = f"https://xchain.io/api/balances/{addr}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 77-77 refactored with the following changes:

@daedalus daedalus merged commit 2d42521 into master Jan 8, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant