Skip to content

Commit 9d1ca63

Browse files
committed
ci: Address some pesky SonarQube false-positive warnings
SonarQube static analysis complains about our use of our `simd::shuffle`, saying we aren't using a cryptographically strong random number generator, hilariously confusing the fact that we have named this operation "shuffle" with the (unrelated!) potential error of not using a good permutation/shuffle algorithm. Also there are complaints about using http: instead of https:, but this isn't a security problem, it's part of the metadata namespacing for XMP. I learned that there's a way to put specific exlusions in sonar-project.properties, so here it is, finally silencing these warnings. Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent ff2ebd8 commit 9d1ca63

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

sonar-project.properties

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,17 @@ sonar.cfamily.build-wrapper-output=/__w/OpenImageIO/OpenImageIO/bw_output
2525
sonar.cfamily.gcov.reportsPath=_coverage
2626
sonar.coverage.exclusions=src/iv/**,src/include/OpenImageIO/detail/pugixml/**,src/include/OpenImageIO/detail/fmt/**,src/libOpenImageIO/kissfft.hh
2727

28+
# Exclude false positives
29+
sonar.issue.ignore.multicriteria=e1,e2
30+
# Stop stupid Sonar from complaining about SIMD shuffle<>, it thinks it is
31+
# weak cryptography, but it's fooled simply by the name "shuffle", and we
32+
# aren't using it for cryptography at all. Sheesh.
33+
sonar.issue.ignore.multicriteria.e1.ruleKey=cpp:S2245
34+
sonar.issue.ignore.multicriteria.e1.resourceKey=**/simd.h,**/simd_test.cpp,**/texturesys.cpp
35+
# Stop stupid Sonar from complaining about using http: instead of https:, but
36+
# we aren't using it to establish a network connection, it's just a key we
37+
# must use for namespacing of XMP metadata groups.
38+
sonar.issue.ignore.multicriteria.e2.ruleKey=cpp:S5332
39+
sonar.issue.ignore.multicriteria.e2.resourceKey=**/xmp.cpp
40+
2841
sonar.verbose=false

src/libtexture/texturesys.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3199,15 +3199,17 @@ TextureSystemImpl::sample_bicubic(
31993199
simd::vfloat4 col[4];
32003200
for (int j = 0; j < 4; ++j) {
32013201
simd::vfloat4 lx = lerp(texel_simd[j][0], texel_simd[j][1],
3202-
shuffle<0>(h) /*h0x*/);
3202+
broadcast_element<0>(h) /*h0x*/);
32033203
simd::vfloat4 rx = lerp(texel_simd[j][2], texel_simd[j][3],
3204-
shuffle<1>(h) /*h1x*/);
3205-
col[j] = lerp(lx, rx, shuffle<1>(g) /*g1x*/);
3204+
broadcast_element<1>(h) /*h1x*/);
3205+
col[j] = lerp(lx, rx, broadcast_element<1>(g) /*g1x*/);
32063206
}
3207-
simd::vfloat4 ly = lerp(col[0], col[1], shuffle<2>(h) /*h0y*/);
3208-
simd::vfloat4 ry = lerp(col[2], col[3], shuffle<3>(h) /*h1y*/);
3207+
simd::vfloat4 ly = lerp(col[0], col[1],
3208+
broadcast_element<2>(h) /*h0y*/);
3209+
simd::vfloat4 ry = lerp(col[2], col[3],
3210+
broadcast_element<3>(h) /*h1y*/);
32093211
simd::vfloat4 weight_simd = weight;
3210-
accum += weight_simd * lerp(ly, ry, shuffle<3>(g) /*g1y*/);
3212+
accum += weight_simd * lerp(ly, ry, broadcast_element<3>(g) /*g1y*/);
32113213
if (daccumds_) {
32123214
simd::vfloat4 scalex = weight_simd * float(spec.width);
32133215
simd::vfloat4 scaley = weight_simd * float(spec.height);

src/libutil/filesystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ Filesystem::unique_path(string_view model)
465465
std::string name;
466466
#endif
467467
static const char chrs[] = "0123456789abcdef";
468-
static std::mt19937 rg { std::random_device {}() };
468+
static std::mt19937 rg { std::random_device {}() }; //NOSONAR
469469
static std::uniform_int_distribution<size_t> pick(0, 15);
470470
static std::mutex mutex;
471471
std::lock_guard<std::mutex> lock(mutex);

0 commit comments

Comments
 (0)