Skip to content

asserts: disallow duplicate devices in request messages - #17401

Open
st3v3nmw wants to merge 2 commits into
canonical:masterfrom
st3v3nmw:reject-duplicate-devices-in-request-message
Open

asserts: disallow duplicate devices in request messages#17401
st3v3nmw wants to merge 2 commits into
canonical:masterfrom
st3v3nmw:reject-duplicate-devices-in-request-message

Conversation

@st3v3nmw

Copy link
Copy Markdown
Member

When parsing the devices header of a request message, snapd previously accepted repeated values without complaint. This PR fixes that.

checkClusterDevices in asserts/cluster.go also fails on error, instead of silently deduplicating.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens validation in the asserts request-message parsing layer by rejecting repeated device identifiers in the devices header, ensuring request targeting is explicit and unambiguous within snapd’s assertion processing.

Changes:

  • Detect and reject duplicate entries in the devices header when decoding request-message assertions.
  • Add a unit test to confirm duplicate devices now produce a deterministic decode error.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
asserts/messages.go Adds duplicate detection to parseDevices while decoding request-message headers.
asserts/messages_test.go Extends invalid decode coverage to assert duplicates in devices are rejected with the expected error.

@st3v3nmw st3v3nmw added the Simple 😃 A small PR which can be reviewed quickly label Jul 23, 2026
@st3v3nmw
st3v3nmw requested review from miguelpires and pedronis July 23, 2026 15:00
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.81%. Comparing base (546cb6a) to head (4f227cc).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17401   +/-   ##
=======================================
  Coverage   78.81%   78.81%           
=======================================
  Files        1410     1406    -4     
  Lines      196929   196862   -67     
  Branches     2498     2498           
=======================================
- Hits       155208   155165   -43     
+ Misses      32367    32347   -20     
+ Partials     9354     9350    -4     
Flag Coverage Δ
unittests 78.81% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

Wed Jul 29 07:21:55 UTC 2026
The following results are from: https://github.com/canonical/snapd/actions/runs/30246137189

Failures:

Preparing:

  • openstack:ubuntu-26.10-64:tests/main/lxd-postrm-purge
  • openstack:ubuntu-26.10-64:tests/main/interfaces-posix-mq

Executing:

  • openstack:opensuse-tumbleweed-64:tests/main/manpages
  • openstack:opensuse-tumbleweed-64:tests/main/services-watchdog
  • openstack:opensuse-tumbleweed-selinux-64:tests/main/manpages
  • openstack:ubuntu-26.10-64:tests/main/xdg-settings
  • openstack:ubuntu-26.10-64:tests/main/broken-seeding
  • openstack:ubuntu-26.10-64:tests/main/bad-interfaces-warn
  • openstack:ubuntu-26.10-64:tests/main/interfaces-location-control
  • openstack:ubuntu-26.10-64:tests/main/lxd
  • openstack:ubuntu-26.10-64:tests/main/apparmor-prompting-integration-tests:write_read_multiple_actioned_by_other_pid_allow_deny
  • openstack:ubuntu-26.10-64:tests/main/apparmor-prompting-integration-tests:write_read_multiple_actioned_by_other_pid_deny_allow
  • openstack:ubuntu-26.10-64:tests/main/upgrade-from-release
  • openstack:ubuntu-26.10-64:tests/main/apparmor-prompting-support

Restoring:

  • openstack:ubuntu-26.10-64:tests/main/apparmor-prompting-integration-tests:write_read_multiple_actioned_by_other_pid_allow_deny
  • openstack:ubuntu-26.10-64:tests/main/
  • openstack:ubuntu-26.10-64:
  • openstack:ubuntu-26.10-64:tests/main/apparmor-prompting-integration-tests:write_read_multiple_actioned_by_other_pid_deny_allow
  • openstack:ubuntu-26.10-64:tests/main/
  • openstack:ubuntu-26.10-64:

Skipped tests from snapd-testing-skip

If you wish to have any of the below tests run in your PR, in your PR description, add 'unskip:' followed by a copy-and-pasted list of the below tests you wish to run (unskip plus test list must be valid yaml)

  • openstack-arm:ubuntu-24.04-arm-64:tests/main/i18n
  • openstack-arm:ubuntu-core-24-arm-64:tests/main/i18n
  • openstack:debian-sid-64:tests/main/interfaces-network-status-classic
  • openstack:debian-sid-64:tests/main/interfaces-xdg-portal-permission-store
  • openstack:ubuntu-24.04-64:tests/main/apparmor-prompting-flag-restart
  • openstack:ubuntu-24.04-64:tests/main/apparmor-prompting-integration-tests
  • openstack:ubuntu-24.04-64:tests/main/apparmor-prompting-prompt-restoration
  • openstack:ubuntu-24.04-64:tests/main/apparmor-prompting-smoke
  • openstack:ubuntu-24.04-64:tests/main/apparmor-prompting-snapd-startup
  • openstack:ubuntu-24.04-64:tests/main/apparmor-prompting-support
  • openstack:ubuntu-24.04-64:tests/main/i18n
  • openstack:ubuntu-24.04-64:tests/main/interfaces-requests-activates-handlers
  • openstack:ubuntu-26.04-64:tests/main/apparmor-prompting-flag-restart
  • openstack:ubuntu-26.04-64:tests/main/apparmor-prompting-integration-tests
  • openstack:ubuntu-26.04-64:tests/main/apparmor-prompting-prompt-restoration
  • openstack:ubuntu-26.04-64:tests/main/apparmor-prompting-smoke
  • openstack:ubuntu-26.04-64:tests/main/apparmor-prompting-snapd-startup
  • openstack:ubuntu-26.04-64:tests/main/apparmor-prompting-support
  • openstack:ubuntu-26.04-64:tests/main/i18n
  • openstack:ubuntu-26.04-64:tests/main/interfaces-requests-activates-handlers

@pedronis pedronis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

@st3v3nmw st3v3nmw added the Auto rerun spread Auto reruns spread up to 4 times in non-draft PRs w/ >=1 approval and <20 fails in any fund. system label Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto rerun spread Auto reruns spread up to 4 times in non-draft PRs w/ >=1 approval and <20 fails in any fund. system Simple 😃 A small PR which can be reviewed quickly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants