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

Add single markdown file target and implement markdown link linter #386

Merged
merged 6 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ jobs:
sudo apt-get --assume-yes update
sudo apt-get --assume-yes install pandoc texlive-xetex texinfo
go install github.com/n0x1m/md2gmi@latest
- name: Linting
run: sh lint.sh
- name: Build ebooks
run: make pdf epub info gmi
run: make pdf epub info gmi one
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: r2book
path: |
r2book.md
r2book.pdf
r2book.epub
r2book.info.gz
Expand Down Expand Up @@ -77,6 +80,7 @@ jobs:
generate_release_notes: true
files: |
r2book.pdf
r2book.md
r2book.epub
r2book.info.gz
r2book-gmi.tar.gz
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ epub:
texi:
pandoc $(CHAPTERS) $(PANDOC_OPTIONS) -o r2book.texi

one r2book.md:
sh one.sh > r2book.md

info: texi
rm -f r2book.info r2book.info.gz
makeinfo --force --no-split r2book.texi
Expand Down
70 changes: 70 additions & 0 deletions lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/sh

posix_pushd() {
if [ $# -eq 0 ]; then
echo "Usage: pushd <directory>"
return 1
fi

DIR=$1
if [ ! -d "${DIR}" ]; then
echo "pushd: ${DIR}: No such directory"
return 1
fi

# Save the current directory on the stack
DIR_STACK="$PWD $DIR_STACK"

# Change to the new directory
cd "${DIR}" || return 1

# Print the new stack
echo "$DIR_STACK"
}

# Function to pop a directory off the stack
posix_popd() {
if [ -z "$DIR_STACK" ]; then
echo "popd: directory stack empty"
return 1
fi

# Extract the first directory from the stack
DIR=$(echo "$DIR_STACK" | awk '{print $1}')
DIR_STACK=$(echo "$DIR_STACK" | cut -d' ' -f2-)

# Change to the directory
cd "$DIR" || return 1

# Print the new stack
echo "$DIR_STACK"
}

RV=0
find_markdown_files() {
(echo "$1" | grep "://") && return
local D=`dirname "$1"`
posix_pushd "$D" > /dev/null
local F=`basename "$1"`
local file="$F"

echo "$PWD/$F"
# Extract referenced markdown files
grep -o '\[.*\](.*\.md)' "$file" | sed -n 's/.*(\(.*\.md\)).*/\1/p' | grep -v :// | while read -r ref; do
if [ -f "$ref" ]; then
find_markdown_files "$ref"
else
echo "\033[31mReferenced file '$ref' not found. From $PWD/$F\033[0m" > /dev/stderr
RV=1
fi
done
posix_popd > /dev/null
}

# Check if a file is provided
F="$1"
[ -z "$1" ] && F=src/SUMMARY.md

# Start the recursive search with the provided file
find_markdown_files "$F"
exit $RV
2 changes: 2 additions & 0 deletions one.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
cat `sh lint.sh`
4 changes: 2 additions & 2 deletions src/analysis/syscalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ the addresses where particular syscalls were found and list them.
...
```

To reduce searching time it is possible to [restrict the searching](../search_bytes/configurating_the_search.md) range for only executable segments or sections with `/as @e:search.in=io.maps.x`
To reduce searching time it is possible to [restrict the searching](../search/configurating_the_search.md) range for only executable segments or sections with `/as @e:search.in=io.maps.x`

Using the [ESIL emulation](emulation.md) radare2 can print syscall arguments in the disassembly output. To enable the linear (but very rough) emulation use `asm.emu` configuration variable:
Using the [ESIL emulation](../emulation/intro.md) radare2 can print syscall arguments in the disassembly output. To enable the linear (but very rough) emulation use `asm.emu` configuration variable:
```
[0x0001ece0]> e asm.emu=true
[0x0001ece0]> s 0x000187c2
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ dir.types: Default path to look for cparse type files

Notice below we have used `ts` command, which basically converts
the C type description (or to be precise it's SDB representation)
into the sequence of `pf` commands. See more about [print format](../basic_commands/print_modes.md).
into the sequence of `pf` commands. See more about [print format](../commandline/print_modes.md).

The `tp` command uses the `pf` string to print all the members of type at the current offset/given address:

Expand Down
2 changes: 1 addition & 1 deletion src/commandline/block_size.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ Another way around is to use special variables `$FB` and `$FS` which denote Func
\ 0x00001f97 c3 ret
```

Note: don't put space after `!` size designator. See also [Command Format](../first_steps/command_format.md).
Note: don't put space after `!` size designator. See also [Command Format](../first_steps/syntax.md).
2 changes: 1 addition & 1 deletion src/commandline/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Most command names in radare are derived from action names. They should be easy to remember, as they are short. Actually, all commands are single letters. Subcommands or related commands are specified using the second character of the command name. For example, `/ foo` is a command to search plain string, while `/x 90 90` is used to look for hexadecimal pairs.

The general format for a valid command (as explained in the [Command Format](../first_steps/command_format.md) chapter) looks like this:
The general format for a valid command (as explained in the [Command Format](../first_steps/syntax.md) chapter) looks like this:

```
[.][times][cmd][~grep][@[@iter]addr!size][|>pipe] ; ...
Expand Down
4 changes: 2 additions & 2 deletions src/commandline/print_modes.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Tip: when using json output, you can append the `~{}` to the command to get a pr
]
```

For more on the magical powers of `~` see the help in `?@?`, and the [Command Format](../first_steps/command_format.md) chapter earlier in the book.
For more on the magical powers of `~` see the help in `?@?`, and the [Command Format](../first_steps/syntax.md) chapter earlier in the book.

### Hexadecimal View

Expand Down Expand Up @@ -435,4 +435,4 @@ e asm.syntax = att
```

You can also check `asm.pseudo`, which is an experimental pseudocode view,
and `asm.esil` which outputs [ESIL](../disassembling/esil.md) ('Evaluable Strings Intermediate Language'). ESIL's goal is to have a human-readable representation of every opcode semantics. Such representations can be evaluated (interpreted) to emulate effects of individual instructions.
and `asm.esil` which outputs [ESIL](../emulation/esil.md) ('Evaluable Strings Intermediate Language'). ESIL's goal is to have a human-readable representation of every opcode semantics. Such representations can be evaluated (interpreted) to emulate effects of individual instructions.
2 changes: 1 addition & 1 deletion src/emulation/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Understanding the distinction between static analysis and dynamic analysis is cr

Radare2 employs its own intermediate language and virtual machine, known as ESIL, for partial emulation (or imprecise full emulation).

Radare2's [ESIL](../disassembling/esil.md) supports partial emulation across all platforms by evaluating those expressions.
Radare2's [ESIL](../emulation/esil.md) supports partial emulation across all platforms by evaluating those expressions.

## Use Cases

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This section aims to explain what are the plugins, how to write them and use the

All of them can be installed via r2pm.

* [r2frida](r2frida.md) - Frida and radare2 better together
* [r2frida](../r2frida/intro.md) - Frida and radare2 better together
* r2ghidra - use the Ghidra decompiler from radare2
* r2dec - a decompiler written in JS for r2
* r2yara - loading, scanning and creating Yara rules
Expand Down
2 changes: 1 addition & 1 deletion src/refcard/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ have to press keys to get the actions happen instead of commands.
| n/N | Seek next/prev function/flag/hit (scr.nkey) |
| C | Toggle (C)olors |
| R | Randomize color palette (ecr) |
| tT | Tab related. see also [tab](visual_panels.md) |
| tT | Tab related. see also [tab](../visual/visual_panels.md) |
| v | Visual code analysis menu |
| V | (V)iew graph (agv?) |
| wW | Seek cursor to next/prev word |
Expand Down
2 changes: 1 addition & 1 deletion src/signatures/zignatures.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ There is an important moment though, if we just run it "as is" - it wont find an
hits: 0
[0x000051c0]>
```
Note the searching address - this is because we need to [adjust the searching](../search_bytes/configurating_the_search.md) range first:
Note the searching address - this is because we need to [adjust the searching](../search/configurating_the_search.md) range first:
```
[0x000051c0]> e search.in=io.section
[0x000051c0]> z/
Expand Down
Loading