@@ -13,8 +13,8 @@ import (
1313
1414// Functions returns the compile-time options that define the functions that
1515// the protobom library exposes to the cel environment.
16- func (* Protobom ) Functions () []cel.EnvOption {
17- return []cel.EnvOption {
16+ func (p * Protobom ) Functions () []cel.EnvOption {
17+ envopt := []cel.EnvOption {
1818 cel .Function (
1919 "get_files" ,
2020 cel .MemberOverload (
@@ -195,15 +195,6 @@ func (*Protobom) Functions() []cel.EnvOption {
195195 ),
196196 ),
197197
198- cel .Function (
199- "load_sbom" ,
200- cel .MemberOverload (
201- "protobom_loadsbom_binding" ,
202- []* cel.Type {elements .ProtobomType , cel .StringType }, elements .DocumentType ,
203- cel .BinaryBinding (functions .LoadSBOM ),
204- ),
205- ),
206-
207198 cel .Function (
208199 "relate_node_list_at_id" ,
209200 cel .MemberOverload (
@@ -254,4 +245,22 @@ func (*Protobom) Functions() []cel.EnvOption {
254245 ),
255246 ),
256247 }
248+
249+ // Here we add all the functions that trigger I/O calls on the host system
250+ // only if the option is enables. Most apps will not need them so we don't
251+ // load them by default.
252+ if p .Options .EnableIO {
253+ envopt = append (
254+ envopt ,
255+ cel .Function (
256+ "load_sbom" ,
257+ cel .MemberOverload (
258+ "protobom_loadsbom_binding" ,
259+ []* cel.Type {elements .ProtobomType , cel .StringType }, elements .DocumentType ,
260+ cel .BinaryBinding (functions .LoadSBOM ),
261+ ),
262+ ),
263+ )
264+ }
265+ return envopt
257266}
0 commit comments