Nikasa, home Request an invite
DocsImport real traffic

Import real traffic

Already have a capture from staging, a browser session or GoReplay files? nk import turns them into packs, one per user session, drops credentials from outside the session and lists what looks personal for you to review.

On this page

If you already have traffic captured from staging, a browser or GoReplay, nk import turns it into packs. You need no tests to record.

A pack from an import is used like any other, with --pack.

What an import does #

nk import makes one pack for each user session. For each pack it:

  • drops credentials from outside the session, and forwarded client addresses;
  • turns secrets in bodies into markers;
  • leaves a token from outside the session as it is, because each compare makes a fresh one.

Import a capture #

Pick the line for the kind of capture you have. Each one writes its packs into packs/ and then runs each pack twice against the old build, as a check.

You have Command
A capture from tcpdump in staging or a mirror session nk import pcap staging.pcapng packs/ --server 10.0.4.7:8080 --state start.dump --check myapp:old --app nk/app.yaml
A HAR export from a browser, Playwright, mitmproxy, Fiddler or Insomnia nk import har session.har packs/ --server https://myapp.example.com --check myapp:old --app nk/app.yaml
Files GoReplay wrote with --output-file nk import gor /var/log/goreplay/ packs/ --server myapp.example.com --check myapp:old --app nk/app.yaml

Options all three share #

Flag What it does
--server Names the app. Without it, Nikasa takes the server that got the most requests.
--session <n> or --max-sessions <k> Keeps fewer sessions.
--dry-run Prints the listing only.
--state <dump> Names a dump taken when the capture started. Without it, records that existed before the capture answer 404.
--check <old-image> --app <file> Runs each pack twice against the old build.
--check-dir Picks where the check's runs go.
--keep-check Keeps the check's runs.

The check lists in review.md each step that did not answer as captured, with its likely cause. It exits 1 when any step missed, and 2 when it could not run.

What each kind of input needs #

A capture #

A capture splits by login (a session cookie or a token's user), else by client address. A quiet gap of 5 minutes starts a new session.

--keys gives TLS keys that are not in the capture.

A HAR file #

A HAR file is one browser, so one session. It is split only when several users sign in.

These are listed and left out:

  • requests to other origins;
  • answers from the browser's own cache;
  • failed requests;
  • WebSockets.

A Playwright .zip works as it is.

GoReplay #

  • Run it with --input-raw-track-response. Otherwise it saves requests only, and no value a response made can be linked.
  • Run it with --input-raw-realip-header X-Real-IP to tell clients apart.

Review personal data #

Fields that look personal are listed in each pack's review.md, by place and never by value. They are:

  • names, email and postal addresses, phone numbers;
  • dates of birth, national ids, card numbers, IBANs;
  • IP addresses.

They stay in the pack. Nikasa does not drop or replace them, and has no command for it.

nk compare refuses such a pack until you do one of these.

Mark the pack as reviewed #

  1. Read the pack's review.md.
  2. If you want the listed values gone, replace them with made-up ones yourself, in inputs/session.hurl and in raw/.
  3. Run nk import reviewed <pack-dir>. It sets the review count in pack.json to 0, and says how many fields it no longer holds against the pack.

Nikasa does not check the values. The command works only on a pack that nk import made.

Accept the pack for one run #

Pass --accept-imported-data. The pack is used as it is, and the report says how many fields went unreviewed.

Next steps #

Written for nk 0.3.14. Something wrong or unclear? Write to hello@nikasa.dev.