MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / Isolate

Function Isolate

pkg/rules/action/isolate_windows.go:229–258  ·  view source on GitHub ↗

Isolate talks to the WFP (Windows Filtering Platform) engine to set up firewall rules that result in complete host isolation. The traffic is allowed for the IP addresses specified in the permitted parameter. If the firewall rules already exist and the whitelist IP addresses are given, the rules are

(whitelist []net.IP)

Source from the content-addressed store, hash-verified

227// are given, the rules are first removed and then recreated with the new
228// allowed IP set.
229func Isolate(whitelist []net.IP) error {
230 if fw == nil {
231 var err error
232 fw, err = newFirewall()
233 if err != nil {
234 return err
235 }
236 }
237
238 if err := fw.findAllowRules(); err != nil {
239 return err
240 }
241
242 switch {
243 case fw.hasAllowRules():
244 // rules were added and no new permitted
245 // addresses are supplied in the action
246 return nil
247 default:
248 // rules were not added, so we set up
249 // the rule to allow localhost in/out
250 // traffic in addition to permitted
251 // IP address.
252 // Block the remaining in/out traffic
253 if err := fw.allow(whitelist); err != nil {
254 return err
255 }
256 return fw.deny()
257 }
258}

Callers 1

processActionsMethod · 0.92

Calls 5

newFirewallFunction · 0.85
findAllowRulesMethod · 0.80
hasAllowRulesMethod · 0.80
allowMethod · 0.80
denyMethod · 0.80

Tested by

no test coverage detected