Skip to content

fix(graph): don't put ':' in node file names on Windows - #1313

Merged
evilsocket merged 1 commit into
bettercap:masterfrom
arxhr007:fix/1280-graph-windows-filenames
Nov 3, 2026
Merged

evilsocket merged 1 commit into
bettercap:masterfrom
arxhr007:fix/1280-graph-windows-filenames

Conversation

@arxhr007

Copy link
Copy Markdown

Fixes #1280

graph on fails on Windows with The filename, directory name, or volume label syntax is incorrect. The graph module names each node file after its key, e.g. endpoint_8c:1d:89:fe:12:eb.json, and Windows can't create files with : in the name.

All node file names now go through one helper (Graph.nodeFile). On Windows it replaces the characters Windows rejects (< > : " / \ | ? *) with _. On other platforms the name is left as it is, so graph databases already on disk for Linux and macOS keep working. Node IDs and the keys in edges.json are unchanged; only the file name differs.

Tests (modules/graph/graph_test.go):

  • TestSafeFileName: table test of the name mapping, with windows true and false.
  • TestNodeFileRoundTrip: creates a node with a MAC id and reads it back through FindNode.
  • TestEachNodeReadsBackNodes: the EachNode walk that graph on does.

The two round-trip tests fail on Windows without the change, with the same error as in the issue, and pass with it.

What I could not check:

  • A full graph on run on Windows with a live network. I only ran the module's tests.
  • The tests on Linux: the WSL build stopped at the missing pcap.h. The non-Windows path is only covered by the safeFileName unit test.
  • go build ./... on my Windows box fails in cgo (no 64-bit gcc), with or without this change.

I used an AI assistant while working on this.

Node files are named after their key, e.g. endpoint_8c:1d:89:fe:12:eb.json.
Windows can't create files with ':' in the name, so `graph on` failed with
"The filename, directory name, or volume label syntax is incorrect" as
soon as a node had to be read or written.

Build the file name through one helper that replaces the characters
Windows rejects with '_' there and leaves the names untouched elsewhere,
so existing graph databases on Linux and macOS keep working.

Fixes #1280
@evilsocket
evilsocket merged commit 3a24dd3 into bettercap:master Nov 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

graph module not working on Windows platform

2 participants