Skip to content

Commit

Permalink
Fix PDF rendering (#252)
Browse files Browse the repository at this point in the history
* Fix pdf rendering issues

* Fix pdf rendering issues

* Update README.md
  • Loading branch information
svkirillov authored Jul 29, 2024
1 parent 600ae6f commit 21eaa2d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
19 changes: 1 addition & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,24 +404,7 @@ Options:
--workers int The number of workers to scan (default 5)
```
The listed options can be passed to GoTestWAF as follows:
* If running the GoTestWAF Docker container, pass the configuration options in the `docker run` command after the Docker image name.
For example, to run GoTestWAF with WebSocket check, you can specify the WebSocket URL via the `wsURL` option:
```sh
docker run --rm --network="host" -it -v ${PWD}/reports:/app/reports \
wallarm/gotestwaf --url=http://127.0.0.1:8080/ --wsURL=ws://127.0.0.1:8080/api/ws
```
* If running GoTestWAF with `go run`, pass the configuration options and its values as the parameters for the main script.
For example, to run GoTestWAF with WebSocket check, you can specify the WebSocket URL via the `wsURL` option:
```sh
go run ./cmd --url=http://127.0.0.1:8080/ --wsURL=ws://127.0.0.1:8080/api/ws
```
GoTestWAF supports two HTTP clients for performing requests, selectable via the `--httpClient` option. The default client is the standard Golang HTTP client. The second option is Chrome, which can be used with the `--httpClient=chrome` CLI argument. Note that on Linux systems, you must add the `--cap-add=SYS_ADMIN` argument to the Docker arguments to run GoTestWAF with Chrome as the request performer.
### Report name
Expand Down
26 changes: 24 additions & 2 deletions internal/report/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,31 @@ import (
"github.com/pkg/errors"
)

// chromium-browser \
// --headless \
// --no-zygote \
// --single-process \
// --no-sandbox \
// --disable-gpu \
// --run-all-compositor-stages-before-draw \
// --no-pdf-header-footer \
// --print-to-pdf=test.pdf \
// report.html

var chromeDPExecAllocatorOptions = append(
chromedp.DefaultExecAllocatorOptions[:],
chromedp.Flag("no-zygote", true),
chromedp.Flag("no-sandbox", true),
chromedp.Flag("disable-gpu", true),
chromedp.Flag("run-all-compositor-stages-before-draw", true),
)

func renderToPDF(ctx context.Context, fileToRenderURL string, pathToResultPDF string) error {
chromeCtx, cancel := chromedp.NewContext(ctx)
defer cancel()
allocCtx, allocCtxCancel := chromedp.NewExecAllocator(ctx, chromeDPExecAllocatorOptions...)
defer allocCtxCancel()

chromeCtx, chromeCtxCancel := chromedp.NewContext(allocCtx)
defer chromeCtxCancel()

var buf []byte

Expand Down

0 comments on commit 21eaa2d

Please sign in to comment.