Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion extcontainer/action_network_blackhole.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"context"
"encoding/json"
"fmt"
"slices"

"github.com/steadybit/action-kit/go/action_kit_api/v2"
"github.com/steadybit/action-kit/go/action_kit_commons/network"
Expand Down Expand Up @@ -42,7 +43,32 @@
Category: extutil.Ptr("Network"),
Kind: action_kit_api.Attack,
TimeControl: action_kit_api.TimeControlExternal,
Parameters: commonNetworkParameters,
Parameters: slices.Concat(commonNetworkParameters, []action_kit_api.ActionParameter{
{
Name: "ipRuleType",
Label: "IP Rule Type",
Description: extutil.Ptr("Specify iproute2 rule type to configure response."),
Type: action_kit_api.ActionParameterTypeString,
DefaultValue: extutil.Ptr(string(network.IpRuleTypeBlackhole)),

Check failure on line 52 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (containerd)

undefined: network.IpRuleTypeBlackhole

Check failure on line 52 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (docker)

undefined: network.IpRuleTypeBlackhole

Check failure on line 52 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (cri-o)

undefined: network.IpRuleTypeBlackhole
Options: []action_kit_api.ParameterOption{

Check failure on line 53 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (containerd)

cannot use []action_kit_api.ParameterOption{…} (value of type []action_kit_api.ParameterOption) as *[]action_kit_api.ParameterOption value in struct literal

Check failure on line 53 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (docker)

cannot use []action_kit_api.ParameterOption{…} (value of type []action_kit_api.ParameterOption) as *[]action_kit_api.ParameterOption value in struct literal

Check failure on line 53 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (cri-o)

cannot use []action_kit_api.ParameterOption{…} (value of type []action_kit_api.ParameterOption) as *[]action_kit_api.ParameterOption value in struct literal
{

Check failure on line 54 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (containerd)

invalid composite literal element type action_kit_api.ParameterOption

Check failure on line 54 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (docker)

invalid composite literal element type action_kit_api.ParameterOption

Check failure on line 54 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (cri-o)

invalid composite literal element type action_kit_api.ParameterOption
action_kit_api.ExplicitParameterOption{
Label: "Blackhole (silently drop packets)",
Value: string(network.IpRuleTypeBlackhole),

Check failure on line 57 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (containerd)

undefined: network.IpRuleTypeBlackhole

Check failure on line 57 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (docker)

undefined: network.IpRuleTypeBlackhole

Check failure on line 57 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (cri-o)

undefined: network.IpRuleTypeBlackhole
},
action_kit_api.ExplicitParameterOption{
Label: "Unreachable (drop packets, return ICMP Network Unreachable)",
Value: string(network.IpRuleTypeUnreachable),

Check failure on line 61 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (containerd)

undefined: network.IpRuleTypeUnreachable

Check failure on line 61 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (docker)

undefined: network.IpRuleTypeUnreachable

Check failure on line 61 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (cri-o)

undefined: network.IpRuleTypeUnreachable
},
action_kit_api.ExplicitParameterOption{
Label: "Prohibit (drop packets, return ICMP Communication Prohibited)",
Value: string(network.IpRuleTypeProhibit),

Check failure on line 65 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (containerd)

undefined: network.IpRuleTypeProhibit

Check failure on line 65 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (docker)

undefined: network.IpRuleTypeProhibit

Check failure on line 65 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (cri-o)

undefined: network.IpRuleTypeProhibit
},
},
},
Advanced: extutil.Ptr(true),
},
}),
}
}

Expand All @@ -53,9 +79,12 @@
return nil, nil, err
}

ruleType := extutil.ToString(request.Config["ipRuleType"])

return &network.BlackholeOpts{
Filter: filter,
ExecutionContext: mapToExecutionContext(request),
IpRuleType: network.IpRuleType(ruleType),

Check failure on line 87 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (containerd)

undefined: network.IpRuleType

Check failure on line 87 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (containerd)

unknown field IpRuleType in struct literal of type network.BlackholeOpts

Check failure on line 87 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (docker)

undefined: network.IpRuleType

Check failure on line 87 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (docker)

unknown field IpRuleType in struct literal of type network.BlackholeOpts

Check failure on line 87 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (cri-o)

undefined: network.IpRuleType

Check failure on line 87 in extcontainer/action_network_blackhole.go

View workflow job for this annotation

GitHub Actions / E2E Tests (cri-o)

unknown field IpRuleType in struct literal of type network.BlackholeOpts
}, messages, nil
}
}
Expand Down
Loading