Skip to content

Windows/FirewallRulesList incorrectly skips set with unspecifiedRules applied #1681

Description

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Summary

Taken from #1666 (comment):

The new blocker: unspecifiedRules never executes under dsc config set while the declared rules are converged.

Steps to reproduce

Repro: on a host whose declared rules all match actual state, add one undeclared enabled rule, then run a real dsc config set with unspecifiedRules: {action: disable}. The rule stays enabled. The same config under --what-if reports Would disable unspecified firewall rule '...' — what-if and set disagree.

Expected behavior

`set` should still be applied since `unspecifiedRules` can still cause a change

Actual behavior

since `unspecifiedRules` is `writeOnly`, the synthetic check if already in desired state appears to be true

Error details

Diagnosis (all with the same input):

-l trace of the real config set shows windows_firewall invoked exactly once, with get (the synthetic pretest) — the set operation is never launched.
Cause is in invoke_set (command_resource.rs): with implementsPretest: false, the engine tests first and early-returns on in_desired_state && ExecutionKind::Actual. Since https://github.com/PowerShell/DSC/pull/1674 that test correctly skips writeOnly properties — but the same test now gates execution of the only operation that acts on the instruction. The guard being Actual-only is also why --what-if still reaches the resource.
dsc resource set with the byte-identical input does sweep (that path skips the pretest), and if any declared rule drifts in the same run, config set executes and sweeps correctly too — so the resource's sweep logic is fine; it's purely the config-engine skip.
Possible fixes, in rough preference order: (a) mark the resource implementsPretest: true — its set is already idempotent (already-disabled rules are skipped), so this looks like a one-line manifest change; (b) more generally, don't skip set when the desired state contains a writeOnly property — by definition the test cannot see the work set would do; (c) purge-aware get/test, which would also make test honest about unspecified-rule drift — the biggest change, and (a) or (b) are enough for us.

One doc note regardless of fix: with writeOnly, dsc config test reports converged even when enabled undeclared rules sit in scope — enforcement happens at set time only. Worth a line so nobody builds compliance reporting on test with this property.

Environment data

3.3-rc.2 pre-release

Version

3.3-rc.2 pre-release

Visuals

No response

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions