Skip to content

Commit

Permalink
Few more makefile cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Jun 14, 2024
1 parent 8136bb2 commit a72348c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 34 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ jobs:
wget https://github.com/nowsecure/r2frida/releases/download/${{env.R2V}}/r2frida_${{env.R2V}}_amd64.deb
sudo dpkg -i r2frida_${{env.R2V}}_amd64.deb
- name: Building
run: |
export R2PM_OFFLINE=1
make -C sarif-ts plugin.r2.js
cp sarif-ts/plugin.r2.js sarif.r2.js
run: make
# commented because requires r2-5.9.3
# - name: Running tests
# run: r2r test/db
Expand All @@ -54,12 +51,10 @@ jobs:
run: |
r2pm -ci r2frida > /dev/null
- name: Building
run: |
export R2PM_OFFLINE=1
make -C sarif-ts plugin.r2.js
cp sarif-ts/plugin.r2.js sarif.r2.js
run: make
- name: Running tests
run: r2r test/db
# do not upload twice
# - uses: actions/upload-artifact@v4
# with:
# name: sarif.r2.js
Expand Down
47 changes: 31 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
all:
PLUGDIR=$(shell r2 -H R2_USER_PLUGINS)
SYS_PLUGDIR=$(shell r2 -H R2_LIBR_PLUGINS)

all: sarif.r2.js

r2: sarif.r2.js
r2 -i sarif.r2.js /bin/ls

sarif.r2.js: sarif-ts/plugin.r2.ts
cd sarif-ts/sarif && R2PM_OFFLINE=1 r2pm -r r2frida-compile -o types.js types.ts
cd sarif-ts && R2PM_OFFLINE=1 r2pm -r r2frida-compile -o ../sarif.r2.js plugin.r2.ts

test:
R2R_OFFLINE=1 r2r -i test/db

install:
mkdir -p $(shell r2 -H R2_USER_PLUGINS)
ln -fs $(shell pwd)/sarif.r2.js $(shell r2 -H R2_USER_PLUGINS)/sarif.r2.js
user-install: sarif.r2.js
mkdir -p $(PLUGDIR)
rm -f $(PLUGDIR)/sarif.r2.js
cp -f sarif.r2.js $(PLUGDIR)/sarif.r2.js

user-install:
mkdir -p $(shell r2 -H R2_USER_PLUGINS)
cp -f sarif.r2.js $(shell r2 -H R2_USER_PLUGINS)
user-symstall:
mkdir -p $(PLUGDIR)
rm -f $(PLUGDIR)/sarif.r2.js
ln -fs $(shell pwd)/sarif.r2.js $(PLUGDIR)/sarif.r2.js

user-uninstall:
rm -f $(shell r2 -H R2_USER_PLUGINS)/sarif.r2.js

install:
$(MAKE) user-install PLUGDIR=$(SYS_PLUGDIR)

symstall:
mkdir -p $(shell r2 -H R2_USER_PLUGINS)
ln -fs $(shell pwd)/sarif.r2.js $(shell r2 -H R2_USER_PLUGINS)
$(MAKE) user-symstall PLUGDIR=$(SYS_PLUGDIR)

uninstall user-uninstall:
rm -f $(shell r2 -H R2_USER_PLUGINS)/sarif.r2.js
uninstall:
$(MAKE) user-uninstall PLUGDIR=$(SYS_PLUGDIR)

indent:
cat sarif.r2.js | sed -e 's/\t/ /g' > tmp.r2.js
mv tmp.r2.js sarif.r2.js
semistandard --global r2 --fix sarif.r2.js
purge: user-uninstall uninstall

.PHONY: all test install user-install symstall uninstall user-uninstall indent
.PHONY: all test
.PHONY: user-install user-symstall user-uninstall
.PHONY: install symstall uninstall purge
34 changes: 24 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SARIF for Radare2
# SARIF support for Radare2

![ci](https://github.com/radareorg/r2sarif/actions/workflows/ci.yml/badge.svg?branch=main)

Expand All @@ -11,19 +11,33 @@ to import and export SARIF documents (JSON files) into the current session,
allowing the analyst to report and visualize the reported vulnerabilities in
a binary using a standard file format.

## Installation

This is the recommended way to install r2sarif nowadays, in your home and symlinked.

```
$ make && make user-symstall
```

For distro packaging reasons you may want to use make install instead.

Use the classic `user-uninstall` and `uninstall` targets to get rid of it.

## Usage

```
[0x00000000]> sarif?
sarif [action] [arguments]
sarif -h, help - show this help message (-h)
sarif -a, add [r] [c] - add a new sarif finding
sarif -aw,-ae,-an [r] [c] - add warning, error or note
sarif -i, import [file] - import sarif info from given file
sarif -j, json - print the spotted findings as json to stdout
sarif -r, r2|script - generate r2 script with loaded sarif info
sarif -R, reset - reset reported findings list
sarif -l, rules ([file]) - list or load rules from file
sarif add [L] [id] [M] - add a new result with selected driver
sarif alias [newalias] - create an alias for the sarif command
sarif export - export added rules as sarif json
sarif help - show this help message (-h)
sarif list [help] - list drivers, rules and results
sarif load [file] - import sarif info from given file
sarif r2 - generate r2 script to import current doc results
sarif reset - unload all documents
sarif select [N] - select the nth driver
sarif unload [N] - unload the nth document
sarif version - show plugin version
[0x00000000]>
```

Expand Down

0 comments on commit a72348c

Please sign in to comment.