mirror of
https://github.com/slimtoolkit/slim.git
synced 2025-06-03 04:00:23 +00:00
chore: remove refs to deprecated io/ioutil (#541)
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
This commit is contained in:
parent
09058e2d78
commit
46ac4432f4
@ -2,7 +2,7 @@ package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -348,7 +348,7 @@ var CLI = &cli.Command{
|
||||
}
|
||||
var execFileCmd []byte
|
||||
if len(execFile) > 0 {
|
||||
execFileCmd, err = ioutil.ReadFile(execFile)
|
||||
execFileCmd, err = os.ReadFile(execFile)
|
||||
errutil.FailOn(err)
|
||||
|
||||
if !strings.Contains(continueAfter.Mode, config.CAMExec) {
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
@ -1606,7 +1605,7 @@ func finishCommand(
|
||||
|
||||
if cmdReport.ArtifactLocation != "" {
|
||||
creportPath := filepath.Join(cmdReport.ArtifactLocation, cmdReport.ContainerReportName)
|
||||
if creportData, err := ioutil.ReadFile(creportPath); err == nil {
|
||||
if creportData, err := os.ReadFile(creportPath); err == nil {
|
||||
var creport report.ContainerReport
|
||||
if err := json.Unmarshal(creportData, &creport); err == nil {
|
||||
cmdReport.System = report.SystemMetadata{
|
||||
|
@ -4,7 +4,6 @@ package commands
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -38,7 +37,7 @@ func GetContainerRunOptions(ctx *cli.Context) (*config.ContainerRunOptions, erro
|
||||
}
|
||||
hostConfigFileName := ctx.String(FlagCROHostConfigFile)
|
||||
if len(hostConfigFileName) > 0 {
|
||||
hostConfigBytes, err := ioutil.ReadFile(hostConfigFileName)
|
||||
hostConfigBytes, err := os.ReadFile(hostConfigFileName)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"op": op,
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@ -263,7 +262,7 @@ func ParseTokenSetFile(filePath string) (map[string]struct{}, error) {
|
||||
return tokens, err
|
||||
}
|
||||
|
||||
fileData, err := ioutil.ReadFile(fullPath) //[]byte
|
||||
fileData, err := os.ReadFile(fullPath) //[]byte
|
||||
if err != nil {
|
||||
return tokens, err
|
||||
}
|
||||
@ -492,7 +491,7 @@ func ParsePathsFile(filePath string) (map[string]*fsutil.AccessInfo, error) {
|
||||
return paths, err
|
||||
}
|
||||
|
||||
fileData, err := ioutil.ReadFile(fullPath) //[]byte
|
||||
fileData, err := os.ReadFile(fullPath) //[]byte
|
||||
if err != nil {
|
||||
return paths, err
|
||||
}
|
||||
@ -550,7 +549,7 @@ func ParsePathsCreportFile(filePath string) (map[string]*fsutil.AccessInfo, erro
|
||||
return paths, err
|
||||
}
|
||||
|
||||
fileData, err := ioutil.ReadFile(fullPath) //[]byte
|
||||
fileData, err := os.ReadFile(fullPath) //[]byte
|
||||
if err != nil {
|
||||
return paths, err
|
||||
}
|
||||
@ -782,7 +781,7 @@ func ParseHTTPProbeExecFile(filePath string) ([]string, error) {
|
||||
return appCalls, err
|
||||
}
|
||||
|
||||
fileData, err := ioutil.ReadFile(fullPath)
|
||||
fileData, err := os.ReadFile(fullPath)
|
||||
if err != nil {
|
||||
return appCalls, err
|
||||
}
|
||||
@ -820,7 +819,7 @@ func ParseLinesWithCommentsFile(filePath string) ([]string, error) {
|
||||
return output, err
|
||||
}
|
||||
|
||||
fileData, err := ioutil.ReadFile(fullPath)
|
||||
fileData, err := os.ReadFile(fullPath)
|
||||
if err != nil {
|
||||
return output, err
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -215,7 +214,7 @@ func NewConfigInfo(
|
||||
cv.BaseComposeDir = workingDir
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadFile(fullComposeFilePath)
|
||||
b, err := os.ReadFile(fullComposeFilePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -979,7 +978,7 @@ func EnvVarsFromService(varMap types.MappingWithEquals, varFiles types.StringLis
|
||||
}
|
||||
|
||||
for _, file := range varFiles {
|
||||
data, err := ioutil.ReadFile(file)
|
||||
data, err := os.ReadFile(file)
|
||||
if err != nil {
|
||||
log.Debugf("compose.EnvVarsFromService: error reading '%s' - %v", file, err)
|
||||
continue
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -490,7 +489,7 @@ func (p *CustomProbe) Start() {
|
||||
|
||||
if res != nil {
|
||||
if res.Body != nil {
|
||||
io.Copy(ioutil.Discard, res.Body)
|
||||
io.Copy(io.Discard, res.Body)
|
||||
}
|
||||
|
||||
res.Body.Close()
|
||||
|
@ -35,7 +35,6 @@ import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"mime/multipart"
|
||||
"net"
|
||||
"net/http"
|
||||
@ -438,7 +437,7 @@ func (c *FCGIClient) Request(p map[string]string, req io.Reader) (resp *http.Res
|
||||
if chunked(resp.TransferEncoding) {
|
||||
resp.Body = clientCloser{c, httputil.NewChunkedReader(rb)}
|
||||
} else {
|
||||
resp.Body = clientCloser{c, ioutil.NopCloser(rb)}
|
||||
resp.Body = clientCloser{c, io.NopCloser(rb)}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@ -113,7 +113,7 @@ func loadAPISpecFromEndpoint(client *http.Client, endpoint string) (*openapi3.T,
|
||||
}
|
||||
|
||||
if res.Body != nil {
|
||||
rdata, err := ioutil.ReadAll(res.Body)
|
||||
rdata, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
log.Debugf("http.CustomProbe.loadAPISpecFromEndpoint.response.read - error=%v", err)
|
||||
return nil, err
|
||||
@ -127,7 +127,7 @@ func loadAPISpecFromEndpoint(client *http.Client, endpoint string) (*openapi3.T,
|
||||
}
|
||||
|
||||
func loadAPISpecFromFile(name string) (*openapi3.T, error) {
|
||||
rdata, err := ioutil.ReadFile(name)
|
||||
rdata, err := os.ReadFile(name)
|
||||
if err != nil {
|
||||
log.Debugf("http.CustomProbe.loadAPISpecFromFile.ReadFile - error=%v", err)
|
||||
return nil, err
|
||||
@ -337,7 +337,7 @@ func (p *CustomProbe) apiSpecEndpointCall(client *http.Client, endpoint, method
|
||||
|
||||
if res != nil {
|
||||
if res.Body != nil {
|
||||
io.Copy(ioutil.Discard, res.Body)
|
||||
io.Copy(io.Discard, res.Body)
|
||||
}
|
||||
|
||||
defer res.Body.Close()
|
||||
|
@ -3,7 +3,6 @@ package seccomp
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@ -123,7 +122,7 @@ func GenProfile(artifactLocation string, profileName string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(profilePath, profileData, 0644)
|
||||
err = os.WriteFile(profilePath, profileData, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -170,7 +169,7 @@ func downloadRelease(logger *log.Entry, localBlobPath, downloadSource string, c
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
if resp != nil && resp.Body != nil {
|
||||
io.Copy(ioutil.Discard, resp.Body)
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
resp.Body.Close()
|
||||
}
|
||||
|
||||
@ -181,7 +180,7 @@ func downloadRelease(logger *log.Entry, localBlobPath, downloadSource string, c
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
logger.Debugf("downloadRelease: unexpected status code - %v", resp.StatusCode)
|
||||
io.Copy(ioutil.Discard, resp.Body)
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
resp.Body.Close()
|
||||
d.Close()
|
||||
os.Remove(localBlobPath)
|
||||
@ -235,7 +234,7 @@ func isGoodDownloadSource(logger *log.Entry, location string) bool {
|
||||
resp, err := client.Do(req)
|
||||
if resp != nil && resp.Body != nil {
|
||||
defer func() {
|
||||
io.Copy(ioutil.Discard, resp.Body)
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
resp.Body.Close()
|
||||
}()
|
||||
}
|
||||
@ -385,6 +384,6 @@ func (pr *progressReader) Close() error {
|
||||
if pr.progress != nil {
|
||||
pr.progress.Stop()
|
||||
}
|
||||
io.Copy(ioutil.Discard, pr.rc)
|
||||
io.Copy(io.Discard, pr.rc)
|
||||
return pr.rc.Close()
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@ -196,7 +195,7 @@ func Check(inContainer, isDSImage bool) *CheckVersionInfo {
|
||||
resp, err := client.Do(req)
|
||||
if resp != nil && resp.Body != nil {
|
||||
defer func() {
|
||||
io.Copy(ioutil.Discard, resp.Body)
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
resp.Body.Close()
|
||||
}()
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
@ -471,7 +470,7 @@ func (a *processor) Archive() error {
|
||||
}
|
||||
}
|
||||
|
||||
artifacts, err := ioutil.ReadDir(a.artifactsDirName)
|
||||
artifacts, err := os.ReadDir(a.artifactsDirName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -781,9 +780,9 @@ func (p *store) resolveLinks() {
|
||||
//the links should be resolved in findSymlinks, but
|
||||
//the current design needs to be improved to catch all symlinks
|
||||
//this is a backup to catch the root level symlinks
|
||||
files, err := ioutil.ReadDir("/")
|
||||
files, err := os.ReadDir("/")
|
||||
if err != nil {
|
||||
log.Debug("resolveLinks - ioutil.ReadDir error: ", err)
|
||||
log.Debug("resolveLinks - os.ReadDir error: ", err)
|
||||
return
|
||||
}
|
||||
|
||||
@ -1186,7 +1185,7 @@ func (p *store) saveCertsData() {
|
||||
if err != nil {
|
||||
log.Debugf("sensor.store.saveCertsData.copyDirs: fsutil.CopyDir(%v,%v) error: %v", fname, dstPath, err)
|
||||
} else if copyLinkTargets {
|
||||
foList, err := ioutil.ReadDir(fname)
|
||||
foList, err := os.ReadDir(fname)
|
||||
if err == nil {
|
||||
log.Debugf("sensor.store.saveCertsData.copyDirs(): dir=%v fcount=%v", fname, len(foList))
|
||||
for _, fo := range foList {
|
||||
@ -1241,7 +1240,7 @@ func (p *store) saveCertsData() {
|
||||
suffix, dirs, subdirPrefix)
|
||||
for _, dirName := range dirs {
|
||||
if subdirPrefix != "" {
|
||||
foList, err := ioutil.ReadDir(dirName)
|
||||
foList, err := os.ReadDir(dirName)
|
||||
if err != nil {
|
||||
log.Debugf("sensor.store.saveCertsData.copyAppCertFiles: os.ReadDir(%v) error - %v", dirName, err)
|
||||
continue
|
||||
@ -2344,11 +2343,11 @@ func (p *store) saveReport() error {
|
||||
return err
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(reportFilePath, reportData.Bytes(), 0644)
|
||||
return os.WriteFile(reportFilePath, reportData.Bytes(), 0644)
|
||||
}
|
||||
|
||||
func getFileHash(artifactFileName string) (string, error) {
|
||||
fileData, err := ioutil.ReadFile(artifactFileName)
|
||||
fileData, err := os.ReadFile(artifactFileName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -2507,7 +2506,7 @@ func rbEnsureGemFiles(src, storeLocation, prefix string) error {
|
||||
gemName := strings.TrimSuffix(file, rbGemSpecExt)
|
||||
|
||||
extBasePath := filepath.Join(base, rgExtSibDir)
|
||||
foList, err := ioutil.ReadDir(extBasePath)
|
||||
foList, err := os.ReadDir(extBasePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -2517,7 +2516,7 @@ func rbEnsureGemFiles(src, storeLocation, prefix string) error {
|
||||
platform := fo.Name()
|
||||
|
||||
extPlatformPath := filepath.Join(extBasePath, platform)
|
||||
foVerList, err := ioutil.ReadDir(extPlatformPath)
|
||||
foVerList, err := os.ReadDir(extPlatformPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -2561,7 +2560,7 @@ func getNuxtConfig(path string) (*nuxtDirs, error) {
|
||||
return nil, fmt.Errorf("sensor: artifact - getNuxtConfig - error getting file => %s", path)
|
||||
}
|
||||
|
||||
dat, err := ioutil.ReadFile(path)
|
||||
dat, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
log.Debugf("sensor: monitor - getNuxtConfig - err reading file => %s - %s", path, err.Error())
|
||||
return nil, fmt.Errorf("sensor: artifact - getNuxtConfig - error reading file => %s", path)
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
@ -345,7 +344,7 @@ func getProcessInfo(pid int32) (*report.ProcessInfo, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rawCmdline, err := ioutil.ReadFile(procFilePath(int(pid), "cmdline"))
|
||||
rawCmdline, err := os.ReadFile(procFilePath(int(pid), "cmdline"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -358,7 +357,7 @@ func getProcessInfo(pid int32) (*report.ProcessInfo, error) {
|
||||
}
|
||||
|
||||
//note: will need to get "environ" at some point :)
|
||||
//rawEnviron, err := ioutil.ReadFile(procFilePath(int(pid), "environ"))
|
||||
//rawEnviron, err := os.ReadFile(procFilePath(int(pid), "environ"))
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
@ -370,7 +369,7 @@ func getProcessInfo(pid int32) (*report.ProcessInfo, error) {
|
||||
info.Name = "unknown"
|
||||
info.ParentPid = -1
|
||||
|
||||
stat, err := ioutil.ReadFile(procFilePath(int(pid), "stat"))
|
||||
stat, err := os.ReadFile(procFilePath(int(pid), "stat"))
|
||||
if err == nil {
|
||||
var procPid int
|
||||
var procName string
|
||||
|
@ -3,7 +3,6 @@ package dockerclient
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@ -61,19 +60,19 @@ func New(config *config.DockerClient) (*docker.Client, error) {
|
||||
newTLSClient := func(host string, certPath string, verify bool) (*docker.Client, error) {
|
||||
var ca []byte
|
||||
|
||||
cert, err := ioutil.ReadFile(filepath.Join(certPath, "cert.pem"))
|
||||
cert, err := os.ReadFile(filepath.Join(certPath, "cert.pem"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
key, err := ioutil.ReadFile(filepath.Join(certPath, "key.pem"))
|
||||
key, err := os.ReadFile(filepath.Join(certPath, "key.pem"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if verify {
|
||||
var err error
|
||||
ca, err = ioutil.ReadFile(filepath.Join(certPath, "ca.pem"))
|
||||
ca, err = os.ReadFile(filepath.Join(certPath, "ca.pem"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -159,5 +159,5 @@ func GenerateFromInfo(
|
||||
dfData.WriteByte('\n')
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(dockerfileLocation, dfData.Bytes(), 0644)
|
||||
return os.WriteFile(dockerfileLocation, dfData.Bytes(), 0644)
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -687,7 +687,7 @@ func stripRunInstArgs(rawInst string) (string, bool, bool, error) {
|
||||
func SaveDockerfileData(fatImageDockerfileLocation string, fatImageDockerfileLines []string) error {
|
||||
var data bytes.Buffer
|
||||
data.WriteString(strings.Join(fatImageDockerfileLines, "\n"))
|
||||
return ioutil.WriteFile(fatImageDockerfileLocation, data.Bytes(), 0644)
|
||||
return os.WriteFile(fatImageDockerfileLocation, data.Bytes(), 0644)
|
||||
}
|
||||
|
||||
func fixJSONArray(in string) string {
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@ -1206,7 +1205,7 @@ func inspectFile(
|
||||
utf8Detector != nil ||
|
||||
(!isKnownCertFile && doDetectAllCertFiles) ||
|
||||
(!isKnownCertFile && doDetectAllCertPKFiles) {
|
||||
data, err := ioutil.ReadAll(reader)
|
||||
data, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1353,7 +1352,7 @@ func inspectFile(
|
||||
}
|
||||
}
|
||||
|
||||
err := ioutil.WriteFile(dumpPath, data, 0644)
|
||||
err := os.WriteFile(dumpPath, data, 0644)
|
||||
if err != nil {
|
||||
fmt.Printf("cmd=xray info=detect.utf8.match.dump.error file='%s' target='%s' error='%s'):\n",
|
||||
fullPath, dumpPath, err)
|
||||
@ -1394,7 +1393,7 @@ func inspectFile(
|
||||
}
|
||||
}
|
||||
|
||||
err := ioutil.WriteFile(dumpPath, data, 0644)
|
||||
err := os.WriteFile(dumpPath, data, 0644)
|
||||
if err != nil {
|
||||
fmt.Printf("cmd=xray info=change.data.hash.match.dump.error file='%s' hash='%s' target='%s' error='%s'):\n",
|
||||
fullPath, hash, dumpPath, err)
|
||||
@ -1442,7 +1441,7 @@ func inspectFile(
|
||||
}
|
||||
}
|
||||
|
||||
err := ioutil.WriteFile(dumpPath, data, 0644)
|
||||
err := os.WriteFile(dumpPath, data, 0644)
|
||||
if err != nil {
|
||||
fmt.Printf("cmd=xray info=change.path.match.dump.error file='%s' ppattern='%s' target='%s' error='%s'):\n",
|
||||
fullPath, cpm.PathPattern, dumpPath, err)
|
||||
@ -1494,7 +1493,7 @@ func inspectFile(
|
||||
}
|
||||
}
|
||||
|
||||
err := ioutil.WriteFile(dumpPath, data, 0644)
|
||||
err := os.WriteFile(dumpPath, data, 0644)
|
||||
if err != nil {
|
||||
fmt.Printf("cmd=xray info=change.data.match.dump.error file='%s' ppattern='%s' dpattern='%s' target='%s' error='%s'):\n",
|
||||
fullPath, cdm.PathPattern, cdm.DataPattern, dumpPath, err)
|
||||
@ -1632,7 +1631,7 @@ func FileDataFromTar(tarPath, filePath string) ([]byte, error) {
|
||||
if hdr.Name == filePath {
|
||||
switch hdr.Typeflag {
|
||||
case tar.TypeReg, tar.TypeSymlink, tar.TypeLink:
|
||||
return ioutil.ReadAll(tr)
|
||||
return io.ReadAll(tr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package imagebuilder
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -200,7 +200,7 @@ func SimpleBuildOptionsFromDockerfileData(data string, ignoreExeInstructions boo
|
||||
}
|
||||
|
||||
func SimpleBuildOptionsFromDockerfile(path string, ignoreExeInstructions bool) (*SimpleBuildOptions, error) {
|
||||
data, err := ioutil.ReadFile(path)
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package pdiscover
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
)
|
||||
@ -27,7 +26,7 @@ func GetProcInfo(pid int) map[string]string {
|
||||
}
|
||||
|
||||
for _, name := range valFields {
|
||||
val, err := ioutil.ReadFile(procFileName(pid, name))
|
||||
val, err := os.ReadFile(procFileName(pid, name))
|
||||
|
||||
if err != nil {
|
||||
return nil
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@ -496,12 +495,12 @@ func (p *Command) saveInfo(info interface{}) bool {
|
||||
err := encoder.Encode(info)
|
||||
errutil.FailOn(err)
|
||||
|
||||
err = ioutil.WriteFile(p.reportLocation, reportData.Bytes(), 0644)
|
||||
err = os.WriteFile(p.reportLocation, reportData.Bytes(), 0644)
|
||||
if err != nil && os.IsPermission(err) {
|
||||
if pinfo, tmpErr := os.Stat(tmpPath); tmpErr == nil && pinfo.IsDir() {
|
||||
p.reportLocation = filepath.Join(tmpPath, DefaultFilename)
|
||||
log.Debugf("report.saveInfo - overriding command report file path to %v", p.reportLocation)
|
||||
err = ioutil.WriteFile(p.reportLocation, reportData.Bytes(), 0644)
|
||||
err = os.WriteFile(p.reportLocation, reportData.Bytes(), 0644)
|
||||
} else {
|
||||
fmt.Printf("report.Command.saveInfo: not saving report file - '%s'\n", p.reportLocation)
|
||||
return false
|
||||
|
@ -3,7 +3,6 @@ package sysenv
|
||||
import (
|
||||
"fmt"
|
||||
"golang.org/x/sys/unix"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
@ -28,7 +27,7 @@ func HasDockerEnvPath() bool {
|
||||
}
|
||||
|
||||
func HasContainerCgroups() bool {
|
||||
if bdata, err := ioutil.ReadFile(procSelfCgroup); err == nil {
|
||||
if bdata, err := os.ReadFile(procSelfCgroup); err == nil {
|
||||
return strings.Contains(string(bdata), ":/docker/")
|
||||
}
|
||||
|
||||
@ -246,7 +245,7 @@ func sysSeccompMode() SeccompModeName {
|
||||
}
|
||||
|
||||
func fileData(fname string) (string, error) {
|
||||
bdata, err := ioutil.ReadFile(fname)
|
||||
bdata, err := os.ReadFile(fname)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package system
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@ -227,7 +226,7 @@ func NewOSShellsFromData(raw []byte) ([]*OSShell, error) {
|
||||
}
|
||||
|
||||
func NewOSShells(verify bool) ([]*OSShell, error) {
|
||||
raw, err := ioutil.ReadFile(OSShellsFile)
|
||||
raw, err := os.ReadFile(OSShellsFile)
|
||||
if err == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
@ -39,7 +39,7 @@ func distroInfo() DistroInfo {
|
||||
DisplayName: "unknown",
|
||||
}
|
||||
|
||||
bdata, err := ioutil.ReadFile(OSReleaseFile)
|
||||
bdata, err := os.ReadFile(OSReleaseFile)
|
||||
if err != nil {
|
||||
return distro
|
||||
}
|
||||
@ -76,7 +76,7 @@ func distroInfo() DistroInfo {
|
||||
|
||||
/*
|
||||
func getOperatingSystem() string {
|
||||
bdata, err := ioutil.ReadFile("/etc/os-release")
|
||||
bdata, err := os.ReadFile("/etc/os-release")
|
||||
if err != nil {
|
||||
print("error reading /etc/os-release")
|
||||
return ""
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@ -241,7 +240,7 @@ func (s *Sensor) StartStandalone(
|
||||
return fmt.Errorf("cannot create %s file: %w", CommandsFileName, err)
|
||||
}
|
||||
|
||||
rawCommands, err := ioutil.ReadFile(commandsFilePath)
|
||||
rawCommands, err := os.ReadFile(commandsFilePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot re-read %s file: %w", CommandsFileName, err)
|
||||
}
|
||||
@ -422,7 +421,7 @@ func (s *Sensor) DownloadArtifacts(ctx context.Context) error {
|
||||
}
|
||||
|
||||
creportFilePath := filepath.Join(s.localArtifactsDirPath(), report.DefaultContainerReportFileName)
|
||||
rawCReport, err := ioutil.ReadFile(creportFilePath)
|
||||
rawCReport, err := os.ReadFile(creportFilePath)
|
||||
if err == nil {
|
||||
s.rawCReport = string(rawCReport)
|
||||
|
||||
@ -711,7 +710,7 @@ func (s *Sensor) AssertArtifactsArchiveContains(
|
||||
continue
|
||||
}
|
||||
|
||||
_, err = ioutil.ReadAll(reader)
|
||||
_, err = io.ReadAll(reader)
|
||||
if err != nil {
|
||||
t.Errorf("Failed reading expected tar archive entry %q: %v", header.Name, err)
|
||||
continue
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -704,7 +703,7 @@ func ReplaceFileData(target string, replace []ReplaceInfo, preserveTimes bool) e
|
||||
ssi = SysStatInfo(rawSysStat)
|
||||
}
|
||||
|
||||
raw, err := ioutil.ReadFile(target)
|
||||
raw, err := os.ReadFile(target)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -726,7 +725,7 @@ func ReplaceFileData(target string, replace []ReplaceInfo, preserveTimes bool) e
|
||||
}
|
||||
|
||||
if replaced {
|
||||
err = ioutil.WriteFile(target, raw, 0644)
|
||||
err = os.WriteFile(target, raw, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -759,7 +758,7 @@ func UpdateFileData(target string, updater DataUpdaterFn, preserveTimes bool) er
|
||||
ssi = SysStatInfo(rawSysStat)
|
||||
}
|
||||
|
||||
raw, err := ioutil.ReadFile(target)
|
||||
raw, err := os.ReadFile(target)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -769,7 +768,7 @@ func UpdateFileData(target string, updater DataUpdaterFn, preserveTimes bool) er
|
||||
return err
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(target, raw, 0644)
|
||||
err = os.WriteFile(target, raw, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1526,7 +1525,7 @@ func LoadStructFromFile(filePath string, out interface{}) error {
|
||||
return err
|
||||
}
|
||||
|
||||
raw, err := ioutil.ReadFile(filePath)
|
||||
raw, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user