-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
59 lines (47 loc) · 1.21 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"io"
"log"
"os"
"workshop/resolver"
)
func run() error {
sbomValidation := false
// Bash: cat super-secret.json | jq -r '.value' | xxd -r -p | rev | base64 -d
pluginResolver := resolver.NewFSPluginResolver(sbomValidation)
plugins := []string{"./out/json", "./out/hex", "./out/reverse", "./out/base64"}
// pluginResolver, cleanupFunc := resolver.NewOCIPluginResolver(
// resolver.WithHostname("ociworkshopacr.azurecr.io"),
// // resolver.WithPort(":5000"),
// // resolver.WithInsecure(),
// resolver.WithPort(""),
// resolver.WithPluginDir("./plugins"),
// resolver.WithValidateSbom(sbomValidation),
// )
// defer cleanupFunc()
// plugins := []string{"json:v0.0.1", "hex:v0.0.1", "reverse:v0.0.1", "base64:v0.0.1"}
// Reader variable for plugin chain
var reader io.Reader
// Initialize with file
reader, err := os.Open("super-secret.json")
if err != nil {
return err
}
for _, plugin := range plugins {
decoderFunc, err := pluginResolver.Resolve(plugin)
if err != nil {
return err
}
reader = decoderFunc(reader)
}
_, err = io.Copy(os.Stdout, reader)
if err != nil {
return err
}
return nil
}
func main() {
if err := run(); err != nil {
log.Fatal(err)
}
}