繁体   English   中英

在 angular 13 项目上运行 checkmarx 时未检查循环条件输入

[英]Unchecked Input For Loop Condition while running checkmarx on angular 13 project

在 angular 13 项目上运行 checkmarx 时,报告导致“循环条件的未检查输入”中等问题。 即使限制了 object 的长度,问题也没有解决。 下面是一段代码:

deepCopy(obj) {
 if (null === obj || "object" !== typeof obj) 
 {return obj};
 if (obj instanceof Array) {
     const copy = [];
     const maxlength=50;
     let len = obj.length;
     if (len > maxlength) {
       len = maxlength
     }
     for (let i = 0; i < len; i++) {
         copy[i] = this.deepCopy(obj[i]);
     }
     return copy;
   
 }

这里 object 被传递给组件服务中定义的这个方法:

     modelChanges(event, type, child) {
    this.value = this._sharedService.deepCopy(this.value);
    this.value[type][child] = event;
  }

Checkmarx 报告说:

src/app/pop/popcreate/popc-define/popc-define.component.html 第 1 行的方法 <div class="jumbotron " style="margin-top: 0.5rem; " [ngStyle]="styleTab">从元素 $event 获取用户输入。 该元素的值在未经验证的情况下流经代码,并最终在 src/app/shared/shared.service.ts 的第 25 行的 deepCopy 中的循环条件中使用。 这构成了循环条件的未检查输入

有什么相关的建议吗?

这个结果是误报。 由于循环明显受到限制,因此这里没有漏洞。 您可能应该将结果标记为“不可利用”并继续生活。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM