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 #2

Merged
merged 1 commit into from
Nov 27, 2023
Merged

Sourcery refactored master branch #2

merged 1 commit into from
Nov 27, 2023

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Nov 27, 2023

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 November 27, 2023 20:03
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Due to GitHub API limits, only the first 60 comments can be shown.

interested = []
interested.append(False)
interested.append(False)
interested = [False, False]
Copy link
Author

Choose a reason for hiding this comment

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

Lines 7-9 refactored with the following changes:

Comment on lines -36 to +34
t = int(random.randint(0, 1))
t = random.randint(0, 1)
Copy link
Author

Choose a reason for hiding this comment

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

Function proc refactored with the following changes:

Comment on lines -24 to +28
opener.addheaders.append(("Content-Type", "text/html;" + buff))
opener.addheaders.append(("Content-Type", f"text/html;{buff}"))
else:
opener.addheaders.append(("Content-Type", "text/html;"))

data = opener.open(url).read()

return data
return opener.open(url).read()
Copy link
Author

Choose a reason for hiding this comment

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

Function check_url refactored with the following changes:

Comment on lines -86 to +90
E = 0xFF
F = 0xFF
G = 0xFF
H = 0xFF

if l > 4:
E = 0x30 + int(N[4])
if l > 5:
F = 0x30 + int(N[5])
if l > 6:
G = 0x30 + int(N[6])
if l > 7:
H = 0x30 + int(N[7])

COMM = [
E = 0x30 + int(N[4]) if l > 4 else 0xFF
F = 0x30 + int(N[5]) if l > 5 else 0xFF
G = 0x30 + int(N[6]) if l > 6 else 0xFF
H = 0x30 + int(N[7]) if l > 7 else 0xFF
return [
Copy link
Author

Choose a reason for hiding this comment

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

Function Attack.encode_pin_cmd refactored with the following changes:

This removes the following comments ( why? ):

# APDU with command pkt

Comment on lines -189 to +177
if args.startpin:
# n= 00274710
n = int(args.startpin)
else:
n = 0

n = int(args.startpin) if args.startpin else 0
Copy link
Author

Choose a reason for hiding this comment

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

Lines 189-194 refactored with the following changes:

This removes the following comments ( why? ):

# n= 00274710

Comment on lines -12 to +14
data = ""
addrs = []

for line in f:
data += line

data = "".join(f)
Copy link
Author

Choose a reason for hiding this comment

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

Function getinputs refactored with the following changes:

Comment on lines -17 to +18
fp = open(f, "r")
d = fp.read()
fp.close()
with open(f, "r") as fp:
d = fp.read()
Copy link
Author

Choose a reason for hiding this comment

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

Function loadfile refactored with the following changes:

fp = open(f, "w")
fp.write(data)
fp.close()
with open(f, "w") as fp:
fp.write(data)
Copy link
Author

Choose a reason for hiding this comment

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

Function savefile refactored with the following changes:

Comment on lines -30 to +28
json_data = str(json.dumps(s))
json_data = json.dumps(s)
Copy link
Author

Choose a reason for hiding this comment

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

Function json2file refactored with the following changes:

Comment on lines -44 to +42
old_nm = file2json(".check_nmap.py." + host + ".cache")
old_nm = file2json(f".check_nmap.py.{host}.cache")
Copy link
Author

Choose a reason for hiding this comment

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

Function getold_nm refactored with the following changes:

Comment on lines -82 to +80
output0 += "tcp %s: %s," % (port, b)
output0 += f"tcp {port}: {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 proc_results refactored with the following changes:

while len(s) == 0:
while not s:
Copy link
Author

Choose a reason for hiding this comment

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

Lines 48-48 refactored with the following changes:

data = ""
for line in fileinput.input():
data += line

data = "".join(fileinput.input())
Copy link
Author

Choose a reason for hiding this comment

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

Lines 85-88 refactored with the following changes:

tmp = 0
for i in range(0, len(s) - 1):
if s[i] == "1":
tmp += 1
return tmp
return sum(1 for i in range(0, len(s) - 1) if s[i] == "1")
Copy link
Author

Choose a reason for hiding this comment

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

Function count_ones refactored with the following changes:

Comment on lines -29 to +25
for i in d[k]:
data.append(i)

data.extend(iter(d[k]))
Copy link
Author

Choose a reason for hiding this comment

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

Lines 29-31 refactored with the following changes:

print("Factodb: " + str(r))
print(f"Factodb: {str(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 send2db refactored with the following changes:

data=[]
#fp=open(sys.argv[1])
for line in fileinput.input():
data.append(line.rstrip())
data = [line.rstrip() for line in fileinput.input()]
Copy link
Author

Choose a reason for hiding this comment

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

Lines 25-28 refactored with the following changes:

This removes the following comments ( why? ):

#fp=open(sys.argv[1])

if len(sys.argv)>3:
fp_dump = open(sys.argv[3],'w')
else:
fp_dump = None

fp_dump = open(sys.argv[3],'w') if len(sys.argv)>3 else None
Copy link
Author

Choose a reason for hiding this comment

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

Lines 37-41 refactored with the following changes:

ipaddr = str(a) + "." + str(b) + "." + str(c) + "." + str(d)
ipaddr = f"{str(a)}.{str(b)}.{str(c)}.{str(d)}"
Copy link
Author

Choose a reason for hiding this comment

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

Lines 39-39 refactored with the following changes:

dt = t2 - t1
return dt
return t2 - t1
Copy link
Author

Choose a reason for hiding this comment

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

Function measure refactored with the following changes:

if big_endian:
return struct.pack(">I", value)
else:
return struct.pack("<I", value)
return struct.pack(">I", value) if big_endian else struct.pack("<I", value)
Copy link
Author

Choose a reason for hiding this comment

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

Function uint32tobytes refactored with the following changes:

Comment on lines -22 to +19
if big_endian:
return struct.pack(">i", value)
else:
return struct.pack("<i", value)
return struct.pack(">i", value) if big_endian else struct.pack("<i", value)
Copy link
Author

Choose a reason for hiding this comment

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

Function int32tobytes refactored with the following changes:

Comment on lines -45 to +51
# Feriados en Uruguay
holidays = [ # feriados no laborables
return [ # feriados no laborables
date(year=year, month=1, day=1), # dia del transportista
date(year=year, month=5, day=1), # dia de los trabajadores
date(year=year, month=7, day=18), # dia de la independencia
date(year=year, month=8, day=25), # dia de la declaratoria de la independencia
date(
year=year, month=8, day=25
), # dia de la declaratoria de la independencia
Copy link
Author

Choose a reason for hiding this comment

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

Function init_holidays refactored with the following changes:

This removes the following comments ( why? ):

# Feriados en Uruguay

d = s2 - s1
return d
return s2 - s1
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 i in xrange(imin, imax):
for _ in xrange(imin, imax):
Copy link
Author

Choose a reason for hiding this comment

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

Function seek refactored with the following changes:

for i in range(MAX_STRETCH):
for _ in range(MAX_STRETCH):
Copy link
Author

Choose a reason for hiding this comment

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

Function stretch_password refactored with the following changes:

h = "0" + h
h = f"0{h}"
Copy link
Author

Choose a reason for hiding this comment

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

Function inttobin refactored with the following changes:

Comment on lines -19 to +29
l = len(plaintext)
n=0
cont = True
while cont:
a = bintoint(plaintext + (" "*n))
b = gmpy2.isqrt(a)
c = b**2
tmp = inttobin(c)
n+=1
cont = not (tmp[0:l] == plaintext)
return b,n
l = len(plaintext)
n=0
cont = True
while cont:
a = bintoint(plaintext + (" "*n))
b = gmpy2.isqrt(a)
c = b**2
tmp = inttobin(c)
n+=1
cont = tmp[:l] != plaintext
return b,n
Copy link
Author

Choose a reason for hiding this comment

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

Function crypt refactored with the following changes:

Comment on lines -16 to +24
print(hostname + ":" + str(port))
print(f"{hostname}:{str(port)}")
try:
pem = ssl.get_server_certificate((hostname, port))
if pem != None:
print(pem)
fp = open("output/%s_%d.pem" % (hostname, port), "w")
fp.write(pem + "\n")
fp.close()
with open("output/%s_%d.pem" % (hostname, port), "w") as fp:
fp.write(pem + "\n")
except:
print(hostname + " error")
print(f"{hostname} error")
Copy link
Author

Choose a reason for hiding this comment

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

Lines 16-25 refactored with the following changes:

Comment on lines -9 to +10
tmp = ""
for byte in val:
tmp += bin(ord(byte)).replace("0b", "")
return "0b" + tmp.zfill(32)
tmp = "".join(bin(ord(byte)).replace("0b", "") for byte in val)
return f"0b{tmp.zfill(32)}"
Copy link
Author

Choose a reason for hiding this comment

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

Function bitrepr32 refactored with the following changes:

@daedalus daedalus merged commit 015125b into master Nov 27, 2023
1 check failed
This pull request was closed.
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