Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions source/common/version/version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ const envoy::config::core::v3::BuildVersion& VersionInfo::buildVersion() {
}

bool VersionInfo::sslFipsCompliant() {
bool fipsCompliant = false;
#ifdef BORINGSSL_FIPS
fipsCompliant = true;
static bool fipsCompliant = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the static? Why not just

#ifdef ENVOY_SSL_FIPS
return true;
#else 
return false;
#endif 

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmarantz Initially I thought this initialization must happen during compile time as "BORINGSSL_FIPS" is being pass during compilation. But it seems like it is not required. Should I change that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you don't need a static at all for this use-case. Just return the value based on the ifdef.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I will change it.

#else
static bool fipsCompliant = false;
#endif
return fipsCompliant;
}
Expand Down
3 changes: 3 additions & 0 deletions test/common/common/version_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class VersionInfoTestPeer {
public:
static const std::string& buildType() { return VersionInfo::buildType(); }
static const std::string& sslVersion() { return VersionInfo::sslVersion(); }
static bool sslFipsCompliant() { return VersionInfo::sslFipsCompliant(); }
static envoy::config::core::v3::BuildVersion makeBuildVersion(const char* version) {
return VersionInfo::makeBuildVersion(version);
}
Expand All @@ -34,6 +35,7 @@ TEST(VersionTest, BuildVersion) {
fields.at(BuildVersionMetadataKeys::get().RevisionStatus).string_value());
EXPECT_EQ(VersionInfoTestPeer::buildType(),
fields.at(BuildVersionMetadataKeys::get().BuildType).string_value());
EXPECT_FALSE(VersionInfoTestPeer::sslFipsCompliant());
Comment thread
PiotrSikora marked this conversation as resolved.
EXPECT_EQ(VersionInfoTestPeer::sslVersion(),
fields.at(BuildVersionMetadataKeys::get().SslVersion).string_value());
}
Expand All @@ -45,6 +47,7 @@ TEST(VersionTest, MakeBuildVersionWithLabel) {
EXPECT_EQ(3, build_version.version().patch());
const auto& fields = build_version.metadata().fields();
EXPECT_GE(fields.size(), 1);
EXPECT_FALSE(VersionInfoTestPeer::sslFipsCompliant());
EXPECT_EQ("foo-bar", fields.at(BuildVersionMetadataKeys::get().BuildLabel).string_value());
}

Expand Down