Skip to content

Commit

Permalink
Update contact_cloud_metadata_service_from_container.go
Browse files Browse the repository at this point in the history
Signed-off-by: Kapil Sharma <ks3913688@gmail.com>
  • Loading branch information
h4l0gen authored and poiana committed Apr 9, 2024
1 parent 375da50 commit ed1efff
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions events/syscall/contact_cloud_metadata_service_from_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,25 @@ limitations under the License.
package syscall

import (
"net"

"os/exec"
"github.com/falcosecurity/event-generator/events"
)

var _ = events.Register(ContactCloudMetadataServiceFromContainer)
var _ = events.Register(
ContactCloudMetadataServiceFromContainer,
events.WithDisabled(), // this rule is not included in falco_rules.yaml (stable rules), so disable the action
)

func ContactCloudMetadataServiceFromContainer(h events.Helper) error {
if h.InContainer() {
conn, err := net.Dial("tcp", "169.254.169.254:80")
if err != nil {
//this event can be use on GCP, AWS and Azure
cmd := exec.Command("timeout", "1s", "nc", "169.254.169.254", "80")

if err := cmd.Run(); err != nil {
return err
}
}

h.Log().Infof("Outbound connection to cloud instance metadata service")
defer conn.Close()
}
return nil
}
}

0 comments on commit ed1efff

Please sign in to comment.