Skip to content

fix(rules): match ssh-add -l after other options in ssh-agent-key-enumeration - #1050

Open
rudycelekli wants to merge 1 commit into
Asymptote-Labs:mainfrom
rudycelekli:fix/ssh-add-list-after-options
Open

rudycelekli wants to merge 1 commit into
Asymptote-Labs:mainfrom
rudycelekli:fix/ssh-add-list-after-options

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

What was wrong

ssh-agent-key-enumeration requires the list flag to be the first argument of ssh-add (ssh-add\s+(-[A-Za-z]*[lL])). Putting any option first hides the listing. So ssh-add -E md5 -l, the usual way to list loaded keys with MD5 fingerprints, went unflagged.

The fix

The -l/-L flag may come after other arguments in the same command: ssh-add\b[^;&|]*\s-[A-Za-z]*[lL]. Adding a key whose path contains -l (ssh-add ~/.ssh/deploy-lab) still does not match, because the flag must start a word. The rule version is now 2.

Tests

I added a match fixture for ssh-add -E md5 -l and a no_match for ssh-add ~/.ssh/deploy-lab. Before the fix:

ssh-agent-key-enumeration/ssh_add_list_with_hash_option: expected match, got no_match

What I ran

cd pkg/asymptoteobserve && go test -count=1 ./...   # all ok (go1.27.2)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant