Dev.to Security πŸ” Cybersecurity πŸ‘ 2 πŸ“– 2 min read

How CloudSlash isolates plugin environment variables and rolls back AWS changes in Go

In the CloudSlash AWS demo, I used the terminal UI to find unused resources, trace their dependencies, and make changes to reduce waste. I checked the changes in the AWS console, then used CloudSlash to restore the delet

In the CloudSlash AWS demo, I used the terminal UI to find unused resources, trace their dependencies, and make changes to reduce waste. I checked the changes in the AWS console, then used CloudSlash to restore the deleted resources and undo the reductions.

The interesting part for me was how to keep AWS-specific logic out of the Go core without reducing the core to a launcher. CloudSlash still needs to show what depends on a resource and give you a way to review a change. The plugin handles what that change actually means in AWS.

Give each plugin its own environment

CloudSlash uses gRPC plugins, with the AWS-specific logic in the AWS plugin. That split is useful for more than keeping provider code out of the core. It also lets us scope the environment variables a plugin receives instead of treating the parent shell’s environment as shared configuration.

In Go, the distinction is easy to miss: if you leave exec.Cmd.Env nil, the child inherits the parent’s environment. To give a child process a scoped environment, you set Cmd.Env explicitly with the variables it needs. The key detail is to build that list deliberately rather than start with os.Environ() and append to it.

That’s environment isolation, not a full process sandbox. It controls what gets passed to the plugin at launch. It doesn’t, by itself, restrict what the plugin can read from disk or reach over the network.

Rollback has to understand the original change

Finding waste and undoing a cleanup are different problems. A dependency graph helps you decide whether a resource is safe to touch, but it doesn’t tell you how to reverse an AWS operation.

For a reduction, the rollback needs to know what setting to put back. For a deletion, it needs enough information to recreate what was removed, assuming that operation supports recreation. That distinction is why the AWS-specific behavior belongs in the plugin, not in the generic graph or terminal UI.

The demo exercised both cases: I saw the cleanup take effect in the AWS console, then saw the changes reversed. That’s a check on the actions shown in the demo, not a promise that every AWS deletion is reversible. Recreating a resource isn’t necessarily the same as recovering its data or preserving its original identity.

If you’re building a plugin system in Go, these are two boundaries worth making explicit: what configuration crosses into the plugin at launch, and which changes the plugin can actually undo.

Source: CloudSlash Core

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.