File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,15 @@ package cmd
18
18
19
19
import (
20
20
"fmt"
21
+ "io"
21
22
"os"
22
23
24
+ "io/ioutil"
25
+
23
26
converter "github.com/falcosecurity/falcoctl/pkg/converter/psp"
24
27
"github.com/kris-nova/logger"
25
28
"github.com/spf13/cobra"
26
29
"github.com/spf13/viper"
27
- "io/ioutil"
28
30
"k8s.io/cli-runtime/pkg/genericclioptions"
29
31
)
30
32
@@ -84,6 +86,9 @@ func convertPspFalcoRules(pspPath string, rulesPath string) error {
84
86
logger .Debug ("Reading PSP from %s" , pspPath )
85
87
86
88
psp , err := ioutil .ReadAll (pspFile )
89
+ if err != nil && err != io .EOF {
90
+ return fmt .Errorf ("Could not read PSP file: %s" , pspPath )
91
+ }
87
92
88
93
conv , err := converter .NewConverter (debugLog , infoLog , errorLog )
89
94
if err != nil {
@@ -95,7 +100,9 @@ func convertPspFalcoRules(pspPath string, rulesPath string) error {
95
100
return fmt .Errorf ("Could not convert psp file to falco rules: %v" , err )
96
101
}
97
102
98
- err = ioutil .WriteFile (rulesPath , []byte (rules ), 0644 )
103
+ if err = ioutil .WriteFile (rulesPath , []byte (rules ), 0644 ); err != nil {
104
+ return fmt .Errorf ("Could not write rules to: %s" , rulesPath )
105
+ }
99
106
100
107
logger .Debug ("Wrote rules to %s" , rulesPath )
101
108
You can’t perform that action at this time.
0 commit comments