我有一个Spring Boot应用程序,并且在调用
getAuthority()
的行上的方法上收到以下SonarQube警告。我该如何解决?
控制权限对安全性敏感。在过去,它导致了以下漏洞:@Service
public class AuthorizationService implements UserDetailsService {
@Autowired
private MRepository mRepository;
public UserDetails loadUserByUsername(String userId) {
MEntity user = mRepository.findByName(userId);
if (user == null) {
throw new UsernameNotFoundException("Invalid username or password.");
}
return new User(user.getName(), user.getPassword(), getAuthority());
}
private List<SimpleGrantedAuthority> getAuthority() { //here i get the warning
return Arrays.asList(new SimpleGrantedAuthority("ROLE_ADMIN"));
}
我有一个Spring Boot应用程序,并且在调用getAuthority()的行上的方法上收到以下SonarQube警告。我该如何解决?控制权限是安全性...
较新版本的SonarQube不仅为您提供代码味道,问题和错误警告,而且还为您提供安全热点。这些并不是您的代码本身的问题。