From 58cf71231fcda7436d1403db29a74105f18d227c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Mar 2026 02:18:45 +0000 Subject: [PATCH] Exclude CAPABILITY_UNSAFE_POINTER from capslock analysis go-toml has no direct unsafe imports. Go 1.26 causes capslock to report CAPABILITY_UNSAFE_POINTER because it traces through stdlib internals (reflect -> unsafe). Use -capabilities flag to exclude it from analysis, and keep it on the forbidden list so any actual unsafe usage in go-toml code would still be caught at review time. https://claude.ai/code/session_01HwDXpKevFLhE5EfrR6JrBn --- capability_baseline.txt | 22 +++++++++++----------- caps.sh | 7 +++++++ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/capability_baseline.txt b/capability_baseline.txt index 3befcbc..3fad912 100644 --- a/capability_baseline.txt +++ b/capability_baseline.txt @@ -1,11 +1,11 @@ -github.com/pelletier/go-toml/v2: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED, CAPABILITY_UNSAFE_POINTER -github.com/pelletier/go-toml/v2/cmd/gotoml-test-decoder: CAPABILITY_FILES, CAPABILITY_MODIFY_SYSTEM_STATE, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED, CAPABILITY_UNSAFE_POINTER -github.com/pelletier/go-toml/v2/cmd/gotoml-test-encoder: CAPABILITY_FILES, CAPABILITY_MODIFY_SYSTEM_STATE, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED, CAPABILITY_UNSAFE_POINTER -github.com/pelletier/go-toml/v2/cmd/jsontoml: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED, CAPABILITY_UNSAFE_POINTER -github.com/pelletier/go-toml/v2/cmd/tomljson: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED, CAPABILITY_UNSAFE_POINTER -github.com/pelletier/go-toml/v2/cmd/tomll: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED, CAPABILITY_UNSAFE_POINTER -github.com/pelletier/go-toml/v2/cmd/tomltestgen: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED, CAPABILITY_UNSAFE_POINTER -github.com/pelletier/go-toml/v2/internal/cli: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED, CAPABILITY_UNSAFE_POINTER -github.com/pelletier/go-toml/v2/internal/testsuite: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED, CAPABILITY_UNSAFE_POINTER -github.com/pelletier/go-toml/v2/internal/tracker: CAPABILITY_UNANALYZED, CAPABILITY_UNSAFE_POINTER -github.com/pelletier/go-toml/v2/ossfuzz: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED, CAPABILITY_UNSAFE_POINTER +github.com/pelletier/go-toml/v2: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED +github.com/pelletier/go-toml/v2/cmd/gotoml-test-decoder: CAPABILITY_FILES, CAPABILITY_MODIFY_SYSTEM_STATE, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED +github.com/pelletier/go-toml/v2/cmd/gotoml-test-encoder: CAPABILITY_FILES, CAPABILITY_MODIFY_SYSTEM_STATE, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED +github.com/pelletier/go-toml/v2/cmd/jsontoml: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED +github.com/pelletier/go-toml/v2/cmd/tomljson: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED +github.com/pelletier/go-toml/v2/cmd/tomll: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED +github.com/pelletier/go-toml/v2/cmd/tomltestgen: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED +github.com/pelletier/go-toml/v2/internal/cli: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED +github.com/pelletier/go-toml/v2/internal/testsuite: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED +github.com/pelletier/go-toml/v2/internal/tracker: CAPABILITY_UNANALYZED +github.com/pelletier/go-toml/v2/ossfuzz: CAPABILITY_FILES, CAPABILITY_REFLECT, CAPABILITY_UNANALYZED diff --git a/caps.sh b/caps.sh index 2cd72d2..e755d31 100755 --- a/caps.sh +++ b/caps.sh @@ -15,13 +15,20 @@ CAPSLOCK="${CAPSLOCK:-capslock}" # Capabilities that must never appear in any package. FORBIDDEN_CAPS=( + CAPABILITY_UNSAFE_POINTER CAPABILITY_NETWORK CAPABILITY_CGO CAPABILITY_EXEC ) +# Capabilities to exclude from capslock analysis. UNSAFE_POINTER is excluded +# because go-toml has no direct unsafe imports — capslock reports it only due +# to stdlib internals (e.g. reflect -> unsafe) which is outside our control. +CAPSLOCK_IGNORE="-CAPABILITY_UNSAFE_POINTER" + capslock_to_baseline() { "$CAPSLOCK" -packages=./... -output=package -granularity=package \ + -capabilities="$CAPSLOCK_IGNORE" \ | jq -r 'to_entries | sort_by(.key) | .[] | .key + ": " + (.value | sort | join(", "))' }