문제

I did come across the following 2 posts about a similar issue Sonar Violation and Sonar Violation But, my problem is with byte[]

Following is the code snippet for which I get this warning in Sonar

public void setValue(byte[] value) {
    this.value = value;
}

I looked at the solutions and made the following changes

public void setValue(byte[] value) {
    if(value == null) {
        this.value = new byte[0];
    } else {
        this.value= Arrays.copyOf(value, value.length); 
    }
}

Even then, I get the same Security violation warning in Sonar. Am I getting this warning because it is byte[] and byte arrays need to be handled differently?

도움이 되었습니까?

해결책

You could use the following to resolve the issue with byte[]

value.clone()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top