Skip to content

Commit aaf2dab

Browse files
whyitforrbs-jacob
andauthored
Use OFRAK_DIR for pytest_ofrak location in build_image.py (#657)
Co-authored-by: Jacob Strieb <[email protected]>
1 parent 90f8479 commit aaf2dab

File tree

23 files changed

+151
-22
lines changed

23 files changed

+151
-22
lines changed

build_image.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,17 @@ def create_dockerfile_finish(config: OfrakImageConfig) -> str:
258258
f"FROM {full_base_image_name}:{config.image_revision}\n\n",
259259
f"ARG OFRAK_SRC_DIR=/\n",
260260
]
261+
262+
# Extract OFRAK_DIR from extra_build_args if present
263+
ofrak_dir_prefix = ""
264+
if config.extra_build_args:
265+
for i, arg in enumerate(config.extra_build_args):
266+
if arg.startswith("OFRAK_DIR"):
267+
ofrak_dir_prefix = arg.split("=", 1)[1]
268+
if ofrak_dir_prefix and not ofrak_dir_prefix.endswith("/"):
269+
ofrak_dir_prefix += "/"
270+
break
271+
261272
package_names = list()
262273
for package_path in config.packages_paths:
263274
package_name = os.path.basename(package_path)
@@ -266,9 +277,11 @@ def create_dockerfile_finish(config: OfrakImageConfig) -> str:
266277
dockerfile_finish_parts.append("\nWORKDIR /\n")
267278
dockerfile_finish_parts.append("ARG INSTALL_TARGET\n")
268279
if config.install_target is InstallTarget.DEVELOP:
269-
dockerfile_finish_parts.append("ADD requirements-dev.txt /\n")
280+
dockerfile_finish_parts.append(f"ADD {ofrak_dir_prefix}requirements-dev.txt /\n")
270281
dockerfile_finish_parts.append("RUN python3 -m pip install -r requirements-dev.txt\n")
271-
dockerfile_finish_parts.append(f"ADD 'pytest_ofrak' $OFRAK_SRC_DIR/pytest_ofrak\n")
282+
dockerfile_finish_parts.append(
283+
f"ADD '{ofrak_dir_prefix}pytest_ofrak' $OFRAK_SRC_DIR/pytest_ofrak\n"
284+
)
272285
dockerfile_finish_parts.append(f"RUN make -C $OFRAK_SRC_DIR/pytest_ofrak develop\n")
273286
develop_makefile = "\\n\\\n".join(
274287
[

docs/README.md

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ Before building the docs, OFRAK, its dependencies, and the `ofrak-ghidra` packag
2525
```
2626
python3 -m venv venv
2727
source venv/bin/activate
28-
for dir in ofrak_type ofrak_io ofrak_patch_maker ofrak_core disassemblers/ofrak_ghidra;
29-
do
30-
make -C $dir develop;
31-
done
28+
make develop
3229
```
3330

3431
## Build the Docs
@@ -52,3 +49,42 @@ OFRAK documentation comes from two sources: manually-written markdown files in `
5249
For writing docstrings that will display well, see the [contributor guidelines](https://ofrak.com/docs/contributor-guide/getting-started.html#docstrings). The list of packages whose docstrings are extracted can be found [in the script that does the extraction](https://github.com/redballoonsecurity/ofrak/blob/master/docs/gen_ref_nav.py#L69-L74).
5350

5451
To add a markdown file to the docs, first write the documentation as a markdown file in the `docs/` directory of the repo. Then, add it to the documentation nav bar by [editing the `nav` property of `mkdocs.yml`](https://github.com/redballoonsecurity/ofrak/blob/master/mkdocs.yml#L50).
52+
53+
### Decorative Footer Images
54+
55+
**Each documentation page must have a decorative footer image at the end:**
56+
57+
```html
58+
<div align="right">
59+
<img src="[PATH]/assets/square_[01-05].png" width="125" height="125">
60+
</div>
61+
```
62+
63+
**Path calculation:**
64+
- Count directory levels from the file to `docs/` root
65+
- Use `../` for each level (e.g., `./assets/`, `../assets/`, `../../assets/`)
66+
67+
**Image selection:**
68+
- Choose any number from 01-05 for visual variety
69+
70+
**Examples:**
71+
```html
72+
<!-- docs/index.md -->
73+
<div align="right">
74+
<img src="./assets/square_02.png" width="125" height="125">
75+
</div>
76+
77+
<!-- docs/install/docker.md -->
78+
<div align="right">
79+
<img src="../assets/square_03.png" width="125" height="125">
80+
</div>
81+
82+
<!-- docs/user-guide/gui/settings.md -->
83+
<div align="right">
84+
<img src="../../assets/square_01.png" width="125" height="125">
85+
</div>
86+
```
87+
88+
<div align="right">
89+
<img src="./assets/square_01.png" width="125" height="125">
90+
</div>

docs/contributor-guide/component/ghidra_components.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,7 @@ If the script requires some arguments, they can also be passed to ``call_script`
9090
Often the OFRAK component needs to get some data back from the Ghidra script. This should be done by storing the data as a JSON string inside a [Ghidra headless variable](https://ghidra.re/ghidra_docs/api/ghidra/app/util/headless/HeadlessScript.html#storeHeadlessValue%28java.lang.String,java.lang.Object)
9191
at the end of the script.
9292
After running each script (e.g. `CustomScript`), the analysis server will get stored headless variable with the name `OfrakResult_<script name>` (e.g. `OfrakResult_CustomScript`) and send its data back to OFRAK. This data is then parsed as JSON and returned by the ``call_script`` method.
93+
94+
<div align="right">
95+
<img src="../../assets/square_02.png" width="125" height="125">
96+
</div>

docs/gen_example_nav.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333

3434
with mkdocs_gen_files.open(Path("examples", doc_path), "w") as f:
3535
# Build relative path to assets directory
36-
animal_path = ("../" * len(module_path.parts)) / (
36+
# Add 1 to account for the "examples" directory itself
37+
animal_path = Path("../" * (len(module_path.parts) + 1)) / (
3738
animals[i % len(animals)].relative_to("docs")
3839
)
3940
print(

docs/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,7 @@ Users interested in using OFRAK for commercial purposes can request the Pro or E
7474

7575
## Support
7676
Please contact [[email protected]](mailto:[email protected]), or write to us on [the OFRAK Slack](https://join.slack.com/t/ofrak/shared_invite/zt-1jku9h6r5-mY7CeeZ4AT8JVmu5YWw2Qg) with any questions or issues regarding OFRAK. We look forward to getting your feedback! Sign up for the [OFRAK Mailing List](https://ofrak.com/sign-up) to receive monthly updates about OFRAK code improvements and new features.
77+
78+
<div align="right">
79+
<img src="./assets/square_02.png" width="125" height="125">
80+
</div>

docs/install/docker.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,7 @@ Additionally:
201201
- **Permission issues**: Add `--user $(id -u):$(id -g)`
202202
- **Can't access GUI**: Check container is running with `docker ps`
203203
- **Out of memory**: Increase Docker memory limit
204+
205+
<div align="right">
206+
<img src="../assets/square_03.png" width="125" height="125">
207+
</div>

docs/install/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,8 @@
2121

2222
## Need Help Choosing?
2323

24-
**Start with PyPI** if you're new to OFRAK. You can always switch methods later.
24+
**Start with PyPI** if you're new to OFRAK. You can always switch methods later.
25+
26+
<div align="right">
27+
<img src="../assets/square_04.png" width="125" height="125">
28+
</div>

docs/install/pypi.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,7 @@ python3.9 -m pip install ofrak
8484
```bash
8585
pip install --user ofrak
8686
```
87+
88+
<div align="right">
89+
<img src="../assets/square_05.png" width="125" height="125">
90+
</div>

docs/install/source.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,7 @@ make requirements-build-docker
125125
## Next Steps
126126

127127
- [Contributor Guide](../contributor-guide/getting-started.md) for development workflow
128+
129+
<div align="right">
130+
<img src="../assets/square_01.png" width="125" height="125">
131+
</div>

docs/license.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,3 +426,7 @@ written and oral agreements and communications relating to the subject matter
426426
of this OFRAK Pro Agreement. In the event of any conflict between this OFRAK
427427
Pro License Agreement and the OFRAK Community License Agreement, located at
428428
<https://ofrak.com/docs/license.html>, this OFRAK Pro Agreement shall control.
429+
430+
<div align="right">
431+
<img src="./assets/square_03.png" width="125" height="125">
432+
</div>

0 commit comments

Comments
 (0)