This repository was archived by the owner on Aug 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 135
This repository was archived by the owner on Aug 25, 2024. It is now read-only.
docs: tutorials: distro: security: binsec operations to scan a distro #595
Copy link
Copy link
Open
Labels
documentationChanges to documentationChanges to documentationp3Average PriorityAverage PrioritysecuritySecurity related issues or improvementsSecurity related issues or improvementstMEsitmated Time To Complete: MediumEsitmated Time To Complete: Medium
Milestone
Description
We introduced the binsec operations back into the main tree recently. We need to use them to write a blog post to compare distros enabling of ALSR.
We could cross this workstream with Rolling Alice: Architecting Alice: OS DecentrAlice as an integration test.
dffml/operations/binsec/dffml_operations_binsec/operations.py
Lines 95 to 139 in d663149
| @op(inputs={"download": URLBytes}, outputs={"rpm": RPMObject}) | |
| async def urlbytes_to_rpmfile(download: URLBytesObject): | |
| fileobj = io.BytesIO(download.body) | |
| try: | |
| rpm = RPMFile(name=download.URL, fileobj=fileobj) | |
| return {"rpm": rpm.__enter__()} | |
| except AssertionError as error: | |
| LOGGER.debug( | |
| "urlbytes_to_rpmfile: Failed to instantiate " "RPMFile(%s): %s", | |
| download.URL, | |
| error, | |
| ) | |
| except RPMError as error: | |
| LOGGER.debug( | |
| "urlbytes_to_rpmfile: Failed to instantiate " "RPMFile(%s): %s", | |
| download.URL, | |
| error, | |
| ) | |
| @op( | |
| inputs={"rpm": RPMObject}, | |
| outputs={"files": rpm_filename}, | |
| expand=["files"], | |
| ) | |
| async def files_in_rpm(rpm: RPMFile): | |
| return {"files": list(map(lambda rpminfo: rpminfo.name, rpm.getmembers()))} | |
| @op( | |
| inputs={"rpm": RPMObject, "filename": rpm_filename}, | |
| outputs={"is_pie": binary_is_PIE}, | |
| ) | |
| async def is_binary_pie(rpm: RPMFile, filename: str) -> Dict[str, Any]: | |
| with rpm.extractfile(filename) as handle: | |
| sig = handle.read(4) | |
| if len(sig) != 4 or sig != b"\x7fELF": | |
| return | |
| handle.seek(0) | |
| return { | |
| "is_pie": bool( | |
| describe_e_type(ELFFile(handle).header.e_type).split()[0] | |
| == "DYN" | |
| ) | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationChanges to documentationChanges to documentationp3Average PriorityAverage PrioritysecuritySecurity related issues or improvementsSecurity related issues or improvementstMEsitmated Time To Complete: MediumEsitmated Time To Complete: Medium