From e74ae88d2a8af9fd032d46b44b09345a044fe826 Mon Sep 17 00:00:00 2001 From: Matthias Hanel Date: Tue, 29 Sep 2020 20:48:06 -0400 Subject: [PATCH] [Fixed] nil import/export on Validate issue Signed-off-by: Matthias Hanel --- exports.go | 8 ++++++++ imports.go | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/exports.go b/exports.go index 5578f98..79d72f3 100644 --- a/exports.go +++ b/exports.go @@ -108,6 +108,10 @@ func (e *Export) IsStreamResponse() bool { // Validate appends validation issues to the passed in results list func (e *Export) Validate(vr *ValidationResults) { + if e == nil { + vr.AddError("null export is not allowed") + return + } if !e.IsService() && !e.IsStream() { vr.AddError("invalid export type: %q", e.Type) } @@ -199,6 +203,10 @@ func (e *Exports) Validate(vr *ValidationResults) error { var streamSubjects []Subject for _, v := range *e { + if v == nil { + vr.AddError("null export is not allowed") + continue + } if v.IsService() { serviceSubjects = append(serviceSubjects, v.Subject) } else { diff --git a/imports.go b/imports.go index 8cd9747..4f6cfb1 100644 --- a/imports.go +++ b/imports.go @@ -53,6 +53,10 @@ func (i *Import) IsStream() bool { // Validate checks if an import is valid for the wrapping account func (i *Import) Validate(actPubKey string, vr *ValidationResults) { + if i == nil { + vr.AddError("null import is not allowed") + return + } if !i.IsService() && !i.IsStream() { vr.AddError("invalid import type: %q", i.Type) } @@ -123,6 +127,10 @@ type Imports []*Import func (i *Imports) Validate(acctPubKey string, vr *ValidationResults) { toSet := make(map[Subject]bool, len(*i)) for _, v := range *i { + if v == nil { + vr.AddError("null import is not allowed") + continue + } if v.Type == Service { if _, ok := toSet[v.To]; ok { vr.AddError("Duplicate To subjects for %q", v.To)