Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CWS] Do not import model package from utils package #33543

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@

//go:build linux

// Package utils holds utils related files
package utils
// Package procfs holds procfs related files
package procfs

import (
"fmt"
"path/filepath"
"strconv"
"strings"

"github.com/DataDog/datadog-agent/pkg/security/secl/model"
"github.com/DataDog/datadog-agent/pkg/security/seclog"
"github.com/DataDog/datadog-agent/pkg/util/kernel"
"github.com/prometheus/procfs"
"github.com/shirou/gopsutil/v4/process"
"golang.org/x/sys/unix"

"github.com/DataDog/datadog-agent/pkg/security/secl/model"
"github.com/DataDog/datadog-agent/pkg/security/seclog"
"github.com/DataDog/datadog-agent/pkg/util/kernel"
)

// GetBoundSockets returns the list of bound sockets for a given process
Expand Down
3 changes: 2 additions & 1 deletion pkg/security/resolvers/resolvers_ebpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/DataDog/datadog-agent/pkg/security/config"
"github.com/DataDog/datadog-agent/pkg/security/probe/erpc"
"github.com/DataDog/datadog-agent/pkg/security/probe/managerhelper"
"github.com/DataDog/datadog-agent/pkg/security/probe/procfs"
"github.com/DataDog/datadog-agent/pkg/security/resolvers/cgroup"
"github.com/DataDog/datadog-agent/pkg/security/resolvers/container"
"github.com/DataDog/datadog-agent/pkg/security/resolvers/dentry"
Expand Down Expand Up @@ -330,7 +331,7 @@ func (r *EBPFResolvers) snapshotBoundSockets() error {
}

for _, proc := range processes {
bs, err := utils.GetBoundSockets(proc)
bs, err := procfs.GetBoundSockets(proc)
if err != nil {
log.Debugf("sockets snapshot failed for (pid: %v): %s", proc.Pid, err)
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/shirou/gopsutil/v4/process"
"golang.org/x/sys/unix"

"github.com/DataDog/datadog-agent/pkg/security/probe/procfs"
"github.com/DataDog/datadog-agent/pkg/security/secl/containerutils"
"github.com/DataDog/datadog-agent/pkg/security/secl/model"
"github.com/DataDog/datadog-agent/pkg/security/seclog"
Expand Down Expand Up @@ -266,7 +267,7 @@ func extractPathFromSmapsLine(line []byte) (string, bool) {
}

func (pn *ProcessNode) snapshotBoundSockets(p *process.Process, stats *Stats, newEvent func() *model.Event) {
boundSockets, err := utils.GetBoundSockets(p)
boundSockets, err := procfs.GetBoundSockets(p)
if err != nil {
seclog.Warnf("error while listing sockets (pid: %v): %s", p.Pid, err)
return
Expand Down
Loading