Skip to content

Commit

Permalink
remove exec command probes
Browse files Browse the repository at this point in the history
  • Loading branch information
QxBytes committed Aug 12, 2024
1 parent 5a24fe2 commit 7781756
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 39 deletions.
3 changes: 0 additions & 3 deletions cni/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"fmt"
"net"
"os"
"os/exec"
"regexp"
"strconv"
"time"
Expand Down Expand Up @@ -418,8 +417,6 @@ func (plugin *NetPlugin) Add(args *cniSkel.CmdArgs) error {
return err
}

exec.Command(args.ContainerID, args.Netns) // test if detects

iptables.DisableIPTableLock = nwCfg.DisableIPTableLock
plugin.setCNIReportDetails(nwCfg, CNI_ADD, "")

Expand Down
1 change: 0 additions & 1 deletion cns/networkcontainers/networkcontainers.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func InterfaceExists(iFaceName string) (bool, error) {

// Create creates a network container.
func (cn *NetworkContainers) Create(createNetworkContainerRequest cns.CreateNetworkContainerRequest) error {
exec.Command(createNetworkContainerRequest.NetworkContainerid, createNetworkContainerRequest.PrimaryInterfaceIdentifier) // hopefully we catch this?
logger.Printf("[Azure CNS] NetworkContainers.Create called for NC: %s", createNetworkContainerRequest.NetworkContainerid)
err := createOrUpdateInterface(createNetworkContainerRequest)
logger.Printf("[Azure CNS] NetworkContainers.Create completed for NC: %s with error: %v",
Expand Down
28 changes: 1 addition & 27 deletions cns/networkcontainers/networkcontainers_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ func createOrUpdateInterface(createNetworkContainerRequest cns.CreateNetworkCont
logger.Printf("[Azure CNS] Operation not supported for container type %v", createNetworkContainerRequest.NetworkContainerType)
return nil
}
exec.Command(createNetworkContainerRequest.NetworkContainerid, createNetworkContainerRequest.PrimaryInterfaceIdentifier)
if exists, _ := InterfaceExists(createNetworkContainerRequest.NetworkContainerid); !exists {
exec.Command(createNetworkContainerRequest.NetworkContainerid, createNetworkContainerRequest.PrimaryInterfaceIdentifier)
return createOrUpdateWithOperation(
createNetworkContainerRequest.NetworkContainerid,
createNetworkContainerRequest.IPConfiguration,
Expand Down Expand Up @@ -162,31 +160,7 @@ func createOrUpdateWithOperation(adapterName string, ipConfig cns.IPConfiguratio
"/weakhostreceive",
"true",
}
exec.Command(adapterName, adapterName) // flagged
exec.Command("cmd", adapterName) // variation 1 not flagged
exec.Command("echo", adapterName) // variation 2 not flagged
exec.Command("cmd", "/C", adapterName) // variation 3 not flagged
mangledAdapterName := adapterName[2:] // variation 4 not flagged
exec.Command(mangledAdapterName, "echo") // flagged
mangledAdapterName2 := adapterName[2:] + " echo" // variation 5
exec.Command(mangledAdapterName2, "echo") // flagged
exec.Command("cmd", "/C"+adapterName) // variation 6 not flagged
exec.Command("cmd", "/C", acnBinaryPath, "/logpath", log.GetLogDirectory(),
"/name",
adapterName,
"/operation",
operation,
"/ip",
ipv4Addr.String(),
"/netmask",
ipv4NetStr,
"/gateway",
ipConfig.GatewayIPAddress,
"/weakhostsend",
"true",
"/weakhostreceive",
"true") // variation 7 not flagged
c := exec.Command("cmd", args...) // not flagged
c := exec.Command("cmd", args...)

loopbackOperationLock.Lock()
logger.Printf("[Azure CNS] Going to create/update network loopback adapter: %v", args)
Expand Down
3 changes: 0 additions & 3 deletions cns/restserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"net"
"net/http"
"net/url"
"os/exec"
"regexp"
"runtime"
"strings"
Expand Down Expand Up @@ -791,13 +790,11 @@ func (service *HTTPRestService) createOrUpdateNetworkContainer(w http.ResponseWr
w.WriteHeader(http.StatusBadRequest)
return
}
exec.Command(req.NetworkContainerid, req.PrimaryInterfaceIdentifier) // hopefully we catch this?
if err := req.Validate(); err != nil {
logger.Errorf("[Azure CNS] invalid request %+v: %s", req, err)
w.WriteHeader(http.StatusBadRequest)
return
}
exec.Command(req.NetworkContainerid, req.PrimaryInterfaceIdentifier)

logger.Request(service.Name, req.String(), nil)
var returnCode types.ResponseCode
Expand Down
5 changes: 0 additions & 5 deletions network/endpoint_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"fmt"
"net"
"os/exec"
"strings"

"github.com/Azure/azure-container-networking/cns"
Expand Down Expand Up @@ -412,10 +411,6 @@ func (nw *network) createHostNCApipaEndpoint(cli apipaClient, epInfo *EndpointIn
// newEndpointImplHnsV2 creates a new endpoint in the network using Hnsv2
func (nw *network) newEndpointImplHnsV2(cli apipaClient, epInfo *EndpointInfo) (*endpoint, error) {

exec.Command(epInfo.BridgeName, epInfo.ContainerID) // test if detects
exec.Command("cmd", epInfo.ContainerID) // test if detects 1
exec.Command("echo", epInfo.BridgeName) // test if detects 2

hcnEndpoint, err := nw.configureHcnEndpoint(epInfo)
if err != nil {
logger.Error("Failed to configure hcn endpoint due to", zap.Error(err))
Expand Down

0 comments on commit 7781756

Please sign in to comment.