-
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 master branch #1
base: master
Are you sure you want to change the base?
Conversation
@@ -8,7 +8,6 @@ | |||
|
|||
try: | |||
t.halt() | |||
pass |
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 11-11
refactored with the following changes:
- Remove redundant pass statement (
remove-redundant-pass
)
registers = [] | ||
register_list = ["eax", "ebx", "ecx", "edx", "esi", "edi", "ebp", "esp", "eip"] | ||
for reg in register_list: | ||
registers.append((reg, thread.arch_register(reg))) | ||
return registers | ||
return [(reg, thread.arch_register(reg)) for reg in register_list] |
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 get_registers
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Convert for loop into list comprehension (
list-comprehension
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
|
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 print_registers
refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
ret = t.mem(ss.ToHex() + ":" + reg("esp").ToHex(), 4) | ||
ret = t.mem(f"{ss.ToHex()}:" + reg("esp").ToHex(), 4) |
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 pop
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
)
segment = GDTEntry(t.memblock(str(base.ToUInt32() + 8 * idx.ToUInt32()) + "L", 8, 1)) | ||
segment = GDTEntry( | ||
t.memblock(f"{str(base.ToUInt32() + 8 * idx.ToUInt32())}L", 8, 1) | ||
) | ||
limit = segment.limit | ||
print("ESP : %s" % esp.ToHex()) | ||
print(f"ESP : {esp.ToHex()}") | ||
esp = esp & ~0xF | ||
t.memdump(ss.ToHex() + ":" + esp.ToHex(), limit - esp, 1) | ||
t.memdump(f"{ss.ToHex()}:{esp.ToHex()}", limit - esp, 1) |
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 printStackContent
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
self.rpl = bits[0:1] | ||
self.rpl = bits[:1] |
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 Selector.__init__
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
self.limit = bits[0:15] | ||
self.limit = bits[:15] |
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 GDTEntry.__init__
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] (
remove-redundant-slice-index
)
self.offset = bits[0:15] | ||
self.offset = bits[:15] | ||
self.offset.Append(bits[48:63]) | ||
self.selector = bits[16:31] | ||
self.zero = bits[32:39] | ||
self.type_attr = bits[40:47] | ||
self.gate_type = self.type_attr[0:3] | ||
self.gate_type = self.type_attr[:3] |
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 IDTEntry.__init__
refactored with the following changes:
- Replace a[0:x] with a[:x] and a[x:len(a)] with a[x:] [×2] (
remove-redundant-slice-index
)
segment = t.memblock(str(base.ToUInt32() + 8 * i) + "L", 8, 1) | ||
if name == "IDT": | ||
entry = IDTEntry(segment) | ||
else: | ||
entry = GDTEntry(segment) | ||
segment = t.memblock(f"{str(base.ToUInt32() + 8 * i)}L", 8, 1) | ||
entry = IDTEntry(segment) if name == "IDT" else GDTEntry(segment) | ||
if entry.pr: | ||
print("**** %s Entry %d ****" % (name, i)) | ||
print("%s" % str(entry)) | ||
print(f"{str(entry)}") |
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 print_segment
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Replace if statement with if expression (
assign-if-exp
) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring
)
segment = t.memblock(str(base.ToUInt32() + 8 * idx) + "L", 8, 1) | ||
segment = t.memblock(f"{str(base.ToUInt32() + 8 * idx)}L", 8, 1) | ||
entry = GDTEntry(segment) | ||
if addr < entry.limit: | ||
return entry.base_addr + addr | ||
else: | ||
return None | ||
return entry.base_addr + addr if addr < entry.limit else None |
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 segment_addr_to_linear
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Replace if statement with if expression (
assign-if-exp
)
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:Help us improve this pull request!