Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Protected Devices in CLI operations #754

Merged
merged 88 commits into from
Aug 28, 2024

Conversation

keeramis
Copy link
Contributor

@keeramis keeramis commented Jul 24, 2024

Description

This PR introduces support for managing Protected Devices similar to Open Devices. When a device is identified as a Protected Device, CLI puts the device in Service Mode, executes the CLI operation that is run by the user, and re-enables Device Protection on the device (whether the command succeeds or fails).
If the device is in Service Mode, CLI executes the command and enables Device Protection on the device.

A generic wrapper has been implemented to handle both Open and Protected Devices. This wrapper obtains the USB device handle, executes the requested command (e.g., particle flash xxx), and, if applicable, handles the transition into Service Mode and re-enables Device Protection after command execution.

The output of CLI commands for all device types and platforms remains unchanged, with all handling of Protected Devices occurring seamlessly in the background.

How to Test

Use any device on any platform in any mode (Open / Protected ) and run various CLI commands to ensure proper functionality. Example: particle flash xxx, particle serial xxx, particle wifi xxx

You can use particle device-protection --help to enable Device Protection on your device.

Note that if you are testing Protected Devices starting in DFU mode, CLI is expected to fail the command after a 60 sec timeout for devices on device-os 6.1.0 and 6.1.1. Device-OS fixes to handle Protected Devices in DFU mode are deployed in future 6.2.0 (or current develop-6.x branch). Noted here.

Related Issues / Discussions

https://app.shortcut.com/particle/epic/127955
Device Protection Tooling SDD

Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA
  • Problem and solution clearly stated
  • Tests have been provided
  • [] Docs have been updated
  • CI is passing

@keeramis keeramis force-pushed the feature/automatic-service-mode branch from c39a7cc to 421bc1b Compare August 9, 2024 16:28
@keeramis keeramis force-pushed the feature/automatic-service-mode branch from 75dba31 to 29aafdd Compare August 13, 2024 16:35
@keeramis keeramis changed the title Feature/automatic service mode Protected Device Automation for CLI commands Aug 15, 2024
@keeramis keeramis requested review from monkbroc, hugomontero, sergeuz, wraithan and Dan-Kouba and removed request for Dan-Kouba August 15, 2024 21:29
@keeramis keeramis marked this pull request as ready for review August 15, 2024 21:30
@keeramis keeramis force-pushed the feature/automatic-service-mode branch 2 times, most recently from 84e6b36 to 2817a21 Compare August 21, 2024 23:10
Copy link
Contributor

@hugomontero hugomontero left a comment

Choose a reason for hiding this comment

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

previously reviewed in small PR's

Copy link
Contributor

@wraithan wraithan left a comment

Choose a reason for hiding this comment

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

Played with it on a few (mostly unprotected) devices and commands worked as expected

return key.makeNewKey({ params: {} }).then(() => {
expect(utilities.deferredChildProcess).to.have.property('callCount', 3);
});
// TODO: fill these in
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this meant to be completed before merging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left it for a future PR. A lot of these were skipped and I would like to handle this separately because I am not sensing great urgency in fixing these tests. keys commands are used mostly internally by us

@keeramis keeramis force-pushed the feature/automatic-service-mode branch from 24e0961 to 90d80c0 Compare August 28, 2024 18:13
Copy link
Member

@monkbroc monkbroc left a comment

Choose a reason for hiding this comment

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

Nice work!

@keeramis keeramis merged commit fb91a2c into master Aug 28, 2024
5 checks passed
@keeramis keeramis changed the title Protected Device Automation for CLI commands Add support for Protected Devices in CLI operations Aug 28, 2024
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.

4 participants