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

Add public_network_access and minimal_tls_version column in azure_sql_server table. #371

Merged
merged 2 commits into from
Oct 4, 2021
Merged
Changes from 1 commit
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
36 changes: 24 additions & 12 deletions azure/table_azure_sql_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/turbot/steampipe-plugin-sdk/plugin/transform"

"github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2017-03-01-preview/sql"
sqlv "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2018-06-01-preview/sql"
sqlv3 "github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/v3.0/sql"
)

//// TABLE DEFINITION
Expand Down Expand Up @@ -71,6 +71,18 @@ func tableAzureSQLServer(_ context.Context) *plugin.Table {
Type: proto.ColumnType_STRING,
Transform: transform.FromField("ServerProperties.AdministratorLoginPassword"),
},
{
Name: "minimal_tls_version",
Description: "Minimal TLS version. Allowed values: '1.0', '1.1', '1.2'.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("ServerProperties.MinimalTLSVersion"),
},
{
Name: "public_network_access",
Description: "Whether or not public endpoint access is allowed for this server.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("ServerProperties.PublicNetworkAccess"),
},
{
Name: "version",
Description: "The version of the server.",
Expand Down Expand Up @@ -207,7 +219,7 @@ func listSQLServer(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateDa
return nil, err
}
subscriptionID := session.SubscriptionID
client := sql.NewServersClient(subscriptionID)
client := sqlv3.NewServersClient(subscriptionID)
client.Authorizer = session.Authorizer

result, err := client.List(ctx)
Expand Down Expand Up @@ -244,7 +256,7 @@ func getSQLServer(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateDat
}
subscriptionID := session.SubscriptionID

client := sql.NewServersClient(subscriptionID)
client := sqlv3.NewServersClient(subscriptionID)
client.Authorizer = session.Authorizer

op, err := client.Get(ctx, resourceGroup, name)
Expand Down Expand Up @@ -313,7 +325,7 @@ func listSQLServerPrivateEndpointConnections(ctx context.Context, d *plugin.Quer
subscriptionID := session.SubscriptionID
resourceGroupName := strings.Split(string(*server.ID), "/")[4]

client := sqlv.NewPrivateEndpointConnectionsClient(subscriptionID)
client := sqlv3.NewPrivateEndpointConnectionsClient(subscriptionID)
client.Authorizer = session.Authorizer

op, err := client.ListByServer(ctx, resourceGroupName, *server.Name)
Expand Down Expand Up @@ -500,7 +512,7 @@ func getSQLServerVulnerabilityAssessment(ctx context.Context, d *plugin.QueryDat
subscriptionID := session.SubscriptionID
resourceGroupName := strings.Split(string(*server.ID), "/")[4]

client := sqlv.NewServerVulnerabilityAssessmentsClient(subscriptionID)
client := sqlv3.NewServerVulnerabilityAssessmentsClient(subscriptionID)
client.Authorizer = session.Authorizer

op, err := client.ListByServer(ctx, resourceGroupName, *server.Name)
Expand Down Expand Up @@ -629,7 +641,7 @@ func networkRuleMap(rule sql.VirtualNetworkRule) map[string]interface{} {

// If we return the API response directly, the output will not give
// all the contents of PrivateEndpointConnection
func privateEndpointConnectionMap(conn sqlv.PrivateEndpointConnection) PrivateConnectionInfo {
func privateEndpointConnectionMap(conn sqlv3.PrivateEndpointConnection) PrivateConnectionInfo {
var connection PrivateConnectionInfo
if conn.ID != nil {
connection.PrivateEndpointConnectionId = *conn.ID
Expand All @@ -647,18 +659,18 @@ func privateEndpointConnectionMap(conn sqlv.PrivateEndpointConnection) PrivateCo
}
}
if conn.PrivateLinkServiceConnectionState != nil {
if conn.PrivateLinkServiceConnectionState.ActionsRequired != nil {
connection.PrivateLinkServiceConnectionStateActionsRequired = *conn.PrivateLinkServiceConnectionState.ActionsRequired
if conn.PrivateLinkServiceConnectionState.ActionsRequired != "" {
connection.PrivateLinkServiceConnectionStateActionsRequired = string(conn.PrivateLinkServiceConnectionState.ActionsRequired)
}
if conn.PrivateLinkServiceConnectionState.Status != nil {
connection.PrivateLinkServiceConnectionStateStatus = *conn.PrivateLinkServiceConnectionState.Status
if conn.PrivateLinkServiceConnectionState.Status != "" {
connection.PrivateLinkServiceConnectionStateStatus = string(conn.PrivateLinkServiceConnectionState.Status)
}
if conn.PrivateLinkServiceConnectionState.Description != nil {
connection.PrivateLinkServiceConnectionStateDescription = *conn.PrivateLinkServiceConnectionState.Description
}
}
if conn.ProvisioningState != nil {
connection.ProvisioningState = *conn.ProvisioningState
if conn.ProvisioningState != "" {
connection.ProvisioningState = string(conn.ProvisioningState)
}
}

Expand Down