oficina / equipo Public

awsjob, hosted controller: slice 1a runs with an empty egress set

C1 (R30): Task 17 needs a VM security group with no rules, but the
adapter refused an empty egress set and a dummy one fails the exact
network audit. The adapter now accepts empty egress; the command refuses
a non-empty one in slice 1a, so the audit expects no egress against a
group with no outbound rules.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 919600ea7cf1c3d8dbccdf91368297c464e60cd7 parent 61b7544
6 files changed, +43 −15
  • cmd/equipo-hosted-controller/config.go +4 −7
  • cmd/equipo-hosted-controller/config_test.go +3 −3
  • docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md +12 −0
  • internal/isolatedjob/awsjob/network_test.go +17 −0
  • internal/isolatedjob/awsjob/runner.go +2 −4
  • internal/isolatedjob/awsjob/runner_test.go +5 −1
diff --git a/cmd/equipo-hosted-controller/config.go b/cmd/equipo-hosted-controller/config.go
index 5e716042..819d6342 100644
--- a/cmd/equipo-hosted-controller/config.go
+++ b/cmd/equipo-hosted-controller/config.go
@@ -50,7 +50,8 @@ type fileConfig struct {
// ConnectorARN is the version-qualified ARN of the VPC_EGRESS connector.
ConnectorARN string `json:"connector_arn"`
// Egress is every "address:port" VMs may reach, as the network audit
- // expects it.
+ // expects it. Slice 1a has no egress stack, so it must be empty ([]):
+ // the VM security group has no outbound rules (ruling R30).
Egress []string `json:"egress"`
SNSTopicARN string `json:"sns_topic_arn"`
}
@@ -228,12 +229,8 @@ func (fc fileConfig) awsConfig() (awsjob.Config, error) {
}
ac.Images[d] = awsjob.Image{ARN: img.ARN, Versions: versions}
}
- for _, e := range fc.Egress {
- ap, err := netip.ParseAddrPort(e)
- if err != nil {
- return awsjob.Config{}, fmt.Errorf("egress %q is not address:port", e)
- }
- ac.Egress = append(ac.Egress, ap)
+ if len(fc.Egress) > 0 {
+ return awsjob.Config{}, fmt.Errorf("egress lists %d destinations; slice 1a has no egress stack, so it must be empty", len(fc.Egress))
}
if _, err := awsjob.New(ac, awsjob.NewAPI(nil, nil, nil)); err != nil {
return awsjob.Config{}, err
diff --git a/cmd/equipo-hosted-controller/config_test.go b/cmd/equipo-hosted-controller/config_test.go
index 10b03c54..e1e7512a 100644
--- a/cmd/equipo-hosted-controller/config_test.go
+++ b/cmd/equipo-hosted-controller/config_test.go
@@ -43,7 +43,7 @@ func validConfig(t *testing.T, dir string) fileConfig {
Versions: map[string]string{"small": "1", "large": "2"}}},
Region: "eu-west-1", VPCID: "vpc-1", VMSubnetID: "subnet-1", VMSecurityGroupID: "sg-1",
ConnectorARN: "arn:aws:lambda:eu-west-1:123456789012:network-connector:egress:3",
- Egress: []string{"10.0.1.5:443"},
+ Egress: []string{},
SNSTopicARN: "arn:aws:sns:eu-west-1:123456789012:equipo-hosted",
}
}
@@ -75,7 +75,7 @@ func TestConfigRefusesMissingListenOrKeys(t *testing.T) {
t.Fatalf("valid config: %v", err)
}
if c.listen != "127.0.0.1:8443" || len(c.keys) != 2 || c.keys["op-1"].Role != hostedwire.RoleOperator ||
- !c.ctl.Images[testDigest] || len(c.ctl.Egress) != 1 || len(c.signing) != ed25519.PrivateKeySize {
+ !c.ctl.Images[testDigest] || len(c.ctl.Egress) != 0 || len(c.signing) != ed25519.PrivateKeySize {
t.Fatalf("valid config loaded as %+v", c)
}
if c.ctl.ProviderFingerprint == nil || c.ctl.ProviderFingerprint(testDigest, "small") != c.aws.Fingerprint(testDigest, "small") {
@@ -104,7 +104,7 @@ func TestConfigRefusesMissingListenOrKeys(t *testing.T) {
"no images": func(f *fileConfig) { f.Images = nil },
"bad digest": func(f *fileConfig) { f.Images[0].Digest = "sha256:AA" },
"unqualified connector": func(f *fileConfig) { f.ConnectorARN = "arn:aws:lambda:eu-west-1:123456789012:network-connector:egress" },
- "no egress": func(f *fileConfig) { f.Egress = nil },
+ "egress in slice 1a": func(f *fileConfig) { f.Egress = []string{"10.0.1.5:443"} },
"no SNS topic": func(f *fileConfig) { f.SNSTopicARN = "" },
} {
sub := t.TempDir()
diff --git a/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md b/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md
index 0649323a..a4f6c2f8 100644
--- a/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md
+++ b/docs/superpowers/plans/HOSTED-SLICE1-PROGRESS.md
@@ -954,3 +954,15 @@ Findings from the final whole-branch review (final-A, B1, B2, C), fixed under ru
| Drop the `ageUnsettled` refusal in `Reopen` | `go test ./internal/hostedctl -run 'TestReopenWaitsForRestartReconciliation$' -count=1` | `pause_test.go:236: Reopen before the first refresh = <nil>, want ErrConflict` | yes, passes |
| Drop the restart case in `expire` | `go test ./internal/hostedctl -run 'TestPauseAckAcrossRestartCancelled$' -count=1` | `pause_test.go:209: refresh first false: Quiescent(1) after the restart = <nil>, want ErrGenerationCancelled` | yes, passes |
| Same mutation, simulation | `EQUIPO_SIM_SEEDS=500 go test ./internal/hostedctl -run 'TestLifecycleSimulation' -count=1` | `sim_test.go:94: seed 12 failed at step 38: I5: a3 generation 1 is stored acknowledged; no acknowledgement of it came in time` (also seeds 50, 106) | yes, 500 seeds pass |
+
+### C1: slice 1a runs with no egress (R30)
+
+- `awsjob.Config` accepts an empty egress set (a group with no outbound rules); the command refuses
+ a non-empty `egress` in slice 1a, so `ctl.Egress` is empty and the audit expects `EgressOnly`
+ empty. `TestAuditNetwork/no_egress_against_a_group_with_no_rules` audits a no-rule group: no
+ egress, `OK(nil)` passes, and `OK` against a non-empty set still fails.
+
+| Mutation | Command | Observed failure | Restored |
+| --- | --- | --- | --- |
+| Refuse empty egress in `awsjob.Config.check` again | `go test ./internal/isolatedjob/awsjob -run 'TestNew$\|TestAuditNetwork$' -count=1` | `runner_test.go:208: New(no egress) = isolatedjob: invalid request: awsjob config: no egress destinations, want nil` and `network_test.go:267: New(no egress) = ...` | yes, passes |
+| Accept a non-empty egress in the command | `go test ./cmd/equipo-hosted-controller -run 'TestConfigRefusesMissingListenOrKeys$' -count=1` | `config_test.go:114: egress in slice 1a: config loaded, want a refusal` | yes, passes |
diff --git a/internal/isolatedjob/awsjob/network_test.go b/internal/isolatedjob/awsjob/network_test.go
index be187a02..34567786 100644
--- a/internal/isolatedjob/awsjob/network_test.go
+++ b/internal/isolatedjob/awsjob/network_test.go
@@ -258,6 +258,23 @@ func TestAuditNetwork(t *testing.T) {
})
}
+ // Slice 1a: no egress configured and a group with no rules at all.
+ t.Run("no egress against a group with no rules", func(t *testing.T) {
+ cfg := testConfig()
+ cfg.Egress = nil
+ r, err := New(cfg, &stub{securityGroups: withGroup(func(g *ec2types.SecurityGroup) { g.IpPermissionsEgress = nil })})
+ if err != nil {
+ t.Fatalf("New(no egress) = %v", err)
+ }
+ got, err := r.AuditNetwork(context.Background())
+ if err != nil || len(got.EgressOnly) != 0 || got.OK(cfg.Egress) != nil {
+ t.Fatalf("AuditNetwork = (%+v, %v), want no egress and a pass; OK = %v", got, err, got.OK(cfg.Egress))
+ }
+ if got.OK(want) == nil {
+ t.Fatal("a group with no rules passes against a non-empty egress set")
+ }
+ })
+
t.Run("reads the configured ids", func(t *testing.T) {
var attrs []ec2types.VpcAttributeName
s := &stub{
diff --git a/internal/isolatedjob/awsjob/runner.go b/internal/isolatedjob/awsjob/runner.go
index 892a86e5..f3c5f5f6 100644
--- a/internal/isolatedjob/awsjob/runner.go
+++ b/internal/isolatedjob/awsjob/runner.go
@@ -90,7 +90,8 @@ type Config struct {
VMSecurityGroupID string // the connector's only security group
Images map[isolatedjob.ImageDigest]Image
// Egress is every destination the security group should let VMs
- // reach: the shared proxies.
+ // reach: the shared proxies. Empty means none: the group has no
+ // outbound rules, as in slice 1a, which has no egress stack.
Egress []netip.AddrPort
}
@@ -146,9 +147,6 @@ func (c Config) check() error {
}
}
}
- if len(c.Egress) == 0 {
- return errors.New("no egress destinations")
- }
for _, e := range c.Egress {
if !e.IsValid() || e.Port() == 0 {
return fmt.Errorf("egress %v is not an address and port", e)
diff --git a/internal/isolatedjob/awsjob/runner_test.go b/internal/isolatedjob/awsjob/runner_test.go
index 739bd728..335055bc 100644
--- a/internal/isolatedjob/awsjob/runner_test.go
+++ b/internal/isolatedjob/awsjob/runner_test.go
@@ -202,6 +202,11 @@ func TestNew(t *testing.T) {
if _, err := New(testConfig(), nil); !errors.Is(err, isolatedjob.ErrInvalid) {
t.Errorf("New(nil api) = %v, want ErrInvalid", err)
}
+ none := testConfig()
+ none.Egress = nil // slice 1a: no egress at all
+ if _, err := New(none, &stub{}); err != nil {
+ t.Errorf("New(no egress) = %v, want nil", err)
+ }
for name, change := range map[string]func(*Config){
"no region": func(c *Config) { c.Region = "" },
"no connector": func(c *Config) { c.ConnectorID = "" },
@@ -230,7 +235,6 @@ func TestNew(t *testing.T) {
},
"unknown size": func(c *Config) { c.Images[testDigest].Versions["medium"] = "9" },
"empty version": func(c *Config) { c.Images[testDigest].Versions[isolatedjob.SizeSmall] = "" },
- "no egress": func(c *Config) { c.Egress = nil },
"egress port 0": func(c *Config) { c.Egress = []netip.AddrPort{netip.MustParseAddrPort("10.0.1.10:0")} },
"egress zero": func(c *Config) { c.Egress = []netip.AddrPort{{}} },
} {