Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOTFIX: Fixed issue for default TLS version setting #620

Merged
merged 3 commits into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 11 additions & 6 deletions plugins/azure/sqlserver/sqlServerTlsVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,19 @@ module.exports = {
servers.data.forEach(function(server) {
if (!server.id) return;

if (server.minimalTlsVersion &&
parseFloat(server.minimalTlsVersion) >= desiredVersion) {
helpers.addResult(results, 0,
`SQL server is using TLS version ${server.minimalTlsVersion} which is equal to or higher than desired TLS version ${config.sql_server_min_tls_version}`,
location, server.id);
if (server.minimalTlsVersion) {
if (parseFloat(server.minimalTlsVersion) >= desiredVersion) {
helpers.addResult(results, 0,
`SQL server is using TLS version ${server.minimalTlsVersion} which is equal to or higher than desired TLS version ${config.sql_server_min_tls_version}`,
location, server.id);
} else {
helpers.addResult(results, 2,
`SQL server is using TLS version ${server.minimalTlsVersion} which is less than desired TLS version ${config.sql_server_min_tls_version}`,
location, server.id);
}
} else {
helpers.addResult(results, 2,
`SQL server is using TLS version ${server.minimalTlsVersion} which is less than desired TLS version ${config.sql_server_min_tls_version}`,
'SQL server allows all TLS versions',
location, server.id);
}
});
Expand Down
34 changes: 32 additions & 2 deletions plugins/azure/sqlserver/sqlServerTlsVersion.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ const servers = [
"privateEndpointConnections": [],
"minimalTlsVersion": "1.1",
"publicNetworkAccess": "Enabled"
},
{
"kind": "v12.0",
"location": "eastus",
"tags": {},
"id": "/subscriptions/123/resourceGroups/akhtar-rg/providers/Microsoft.Sql/servers/test-server",
"name": "test-server",
"type": "Microsoft.Sql/servers",
"administratorLogin": "aqua",
"version": "12.0",
"state": "Ready",
"fullyQualifiedDomainName": "test-server.database.windows.net",
"privateEndpointConnections": [],
"publicNetworkAccess": "Enabled"
}
];

Expand Down Expand Up @@ -60,7 +74,23 @@ describe('sqlServerTlsVersion', function() {
};

const cache = createCache(
servers,
[servers[0]],
);

sqlServerTlsVersion.run(cache, { sql_server_min_tls_version: '1.2' }, callback);
});

it('should give failing result if SQL server allows all TLS versions', function(done) {
const callback = (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(2);
expect(results[0].message).to.include('SQL server allows all TLS versions');
expect(results[0].region).to.equal('eastus');
done()
};

const cache = createCache(
[servers[1]],
);

sqlServerTlsVersion.run(cache, { sql_server_min_tls_version: '1.2' }, callback);
Expand All @@ -76,7 +106,7 @@ describe('sqlServerTlsVersion', function() {
};

const cache = createCache(
servers
[servers[0]]
);

sqlServerTlsVersion.run(cache, { sql_server_min_tls_version: '1.0' }, callback);
Expand Down