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

Merged
merged 1 commit into from
Jul 28, 2023
Merged

Sourcery refactored master branch #1

merged 1 commit into from
Jul 28, 2023

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jul 28, 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 X-oss-byte July 28, 2023 16:53
@stackblitz
Copy link

stackblitz bot commented Jul 28, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

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.

Sourcery timed out performing refactorings.

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

Comment on lines -35 to +34
files = dict()
deps: Dict[str, Set[str]] = dict()
files = {}
deps: Dict[str, Set[str]] = {}
Copy link
Author

Choose a reason for hiding this comment

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

Lines 35-89 refactored with the following changes:

This removes the following comments ( why? ):

# Build the transitive closure of dependencies of module

sys.exit('*** %s already has a copyright by The Bitcoin Core developers'
% (filename))
sys.exit(
f'*** {filename} already has a copyright by The Bitcoin Core developers'
)
Copy link
Author

Choose a reason for hiding this comment

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

Function exec_insert_header refactored with the following changes:

Comment on lines -559 to +561
sys.exit("*** bad filename: %s" % filename)
sys.exit(f"*** bad filename: {filename}")
_, extension = os.path.splitext(filename)
if extension not in ['.h', '.cpp', '.cc', '.c', '.py', '.sh']:
sys.exit("*** cannot insert for file extension %s" % extension)
sys.exit(f"*** cannot insert for file extension {extension}")
Copy link
Author

Choose a reason for hiding this comment

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

Function insert_cmd refactored with the following changes:

Comment on lines -69 to +82
outname = os.path.join(mandir, os.path.basename(abspath) + '.1')
outname = os.path.join(mandir, f'{os.path.basename(abspath)}.1')
print(f'Generating {outname}…')
subprocess.run([help2man, '-N', '--version-string=' + verstr, '--include=' + footer.name, '-o', outname, abspath], check=True)
subprocess.run(
[
help2man,
'-N',
f'--version-string={verstr}',
f'--include={footer.name}',
'-o',
outname,
abspath,
],
check=True,
)
Copy link
Author

Choose a reason for hiding this comment

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

Lines 69-71 refactored with the following changes:

Comment on lines -21 to +24
have_gnu_relro = False
for segment in binary.segments:
# Note: not checking p_flags == PF_R: here as linkers set the permission differently
# This does not affect security: the permission flags of the GNU_RELRO program
# header are ignored, the PT_LOAD header determines the effective permissions.
# However, the dynamic linker need to write to this area so these are RW.
# Glibc itself takes care of mprotecting this area R after relocations are finished.
# See also https://marc.info/?l=binutils&m=1498883354122353
if segment.type == lief.ELF.SEGMENT_TYPES.GNU_RELRO:
have_gnu_relro = True

have_gnu_relro = any(
segment.type == lief.ELF.SEGMENT_TYPES.GNU_RELRO
for segment in binary.segments
)
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_ELF_RELRO refactored with the following changes:

  • Use any() instead of for loop (use-any)

This removes the following comments ( why? ):

# This does not affect security: the permission flags of the GNU_RELRO program
# See also https://marc.info/?l=binutils&m=1498883354122353
# header are ignored, the PT_LOAD header determines the effective permissions.
# Note: not checking p_flags == PF_R: here as linkers set the permission differently
# However, the dynamic linker need to write to this area so these are RW.
# Glibc itself takes care of mprotecting this area R after relocations are finished.

Comment on lines -116 to +109
if content.tolist() == [243, 15, 30, 250]: # endbr64
return True
return False
return content.tolist() == [243, 15, 30, 250]
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_ELF_control_flow refactored with the following changes:

This removes the following comments ( why? ):

# endbr64

@X-oss-byte X-oss-byte merged commit 26817a9 into master Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant