未验证 提交 58f50c94 编写于 作者: J Josh van Leeuwen 提交者: GitHub

Ensure parts is longer than 5. Components name validation (#6489)

* Ensure parts is longer than 5. Components name validation
Signed-off-by: Njoshvanl <me@joshvanl.dev>

* Include ObjectMeta in type types
Signed-off-by: Njoshvanl <me@joshvanl.dev>

---------
Signed-off-by: Njoshvanl <me@joshvanl.dev>
Co-authored-by: NArtur Souza <asouza.pro@gmail.com>
上级 e802073c
......@@ -16,11 +16,14 @@ package components
import (
"bufio"
"bytes"
"fmt"
"os"
"path/filepath"
"strings"
"github.com/dapr/dapr/utils"
"k8s.io/apimachinery/pkg/api/validation/path"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/yaml"
)
......@@ -104,7 +107,8 @@ func (m DiskManifestLoader[T]) loadManifestsFromFile(manifestPath string) []T {
}
type typeInfo struct {
metav1.TypeMeta `json:",inline"`
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
}
// decodeYaml decodes the yaml document.
......@@ -136,6 +140,11 @@ func (m DiskManifestLoader[T]) decodeYaml(b []byte) ([]T, []error) {
continue
}
if errs := path.IsValidPathSegmentName(ti.Name); len(errs) > 0 {
errors = append(errors, fmt.Errorf("invalid name %q for %q: %s", ti.Name, m.kind, strings.Join(errs, "; ")))
continue
}
var manifest T
if m.zvFn != nil {
manifest = m.zvFn()
......
......@@ -1545,6 +1545,9 @@ func (a *api) findTargetID(reqCtx *fasthttp.RequestCtx) string {
uri := string(reqCtx.URI().Path())
if strings.HasPrefix(uri, "/v1.0/invoke/") {
parts := strings.Split(uri, "/")
if len(parts) < 5 {
return ""
}
// Example: http://localhost:3500/v1.0/invoke/http://api.github.com/method/<method>
// parts[0]: /
// parts[1]: v1.0
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册