[#360] Reuse single target during policy check
Some checks failed
/ DCO (pull_request) Successful in 1m40s
/ Vulncheck (pull_request) Failing after 1m51s
/ Builds (1.20) (pull_request) Successful in 2m29s
/ Builds (1.21) (pull_request) Successful in 1m44s
/ Lint (pull_request) Successful in 3m57s
/ Tests (1.20) (pull_request) Successful in 2m26s
/ Tests (1.21) (pull_request) Successful in 2m18s
Some checks failed
/ DCO (pull_request) Successful in 1m40s
/ Vulncheck (pull_request) Failing after 1m51s
/ Builds (1.20) (pull_request) Successful in 2m29s
/ Builds (1.21) (pull_request) Successful in 1m44s
/ Lint (pull_request) Successful in 3m57s
/ Tests (1.20) (pull_request) Successful in 2m26s
/ Tests (1.21) (pull_request) Successful in 2m18s
Policy engine library is able to manage multiple targets and resolve different status results. Signed-off-by: Alex Vanin <a.vanin@yadro.com>
This commit is contained in:
parent
b7e15402a1
commit
65a8e2dadc
1 changed files with 10 additions and 16 deletions
|
@ -74,25 +74,19 @@ func policyCheck(r *http.Request, cfg PolicyConfig) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
reqInfo := GetReqInfo(r.Context())
|
reqInfo := GetReqInfo(r.Context())
|
||||||
targets := []engine.RequestTarget{
|
target := engine.NewRequestTargetWithNamespace(reqInfo.Namespace)
|
||||||
engine.NewRequestTargetWithNamespace(reqInfo.Namespace),
|
|
||||||
}
|
|
||||||
if bktInfo != nil {
|
if bktInfo != nil {
|
||||||
targets = append(targets, engine.NewRequestTargetWithContainer(bktInfo.CID.EncodeToString()))
|
cnrTarget := engine.ContainerTarget(bktInfo.CID.EncodeToString())
|
||||||
|
target.Container = &cnrTarget
|
||||||
}
|
}
|
||||||
|
|
||||||
st := chain.NoRuleFound
|
st, found, err := cfg.Storage.IsAllowed(chain.S3, target, req)
|
||||||
for _, target := range targets {
|
|
||||||
status, found, err := cfg.Storage.IsAllowed(chain.S3, target, req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if found {
|
|
||||||
st = status
|
if !found {
|
||||||
if status != chain.Allow {
|
st = chain.NoRuleFound
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
|
Loading…
Reference in a new issue