Skip to content

Commit 227c7e5

Browse files
kyleconroyclaude
andcommitted
Add DROP SERVER AUDIT SPECIFICATION statement support
- Add DropServerAuditSpecificationStatement AST type - Update parser to distinguish DROP SERVER AUDIT from DROP SERVER AUDIT SPECIFICATION - Add missing server audit group name mappings (LOGIN_CHANGE_PASSWORD_GROUP, BROKER_LOGIN_GROUP, SERVER_PRINCIPAL_CHANGE_GROUP, etc.) Enables: ServerAuditSpecificationStatementTests, Baselines100_ServerAuditSpecificationStatementTests, Baselines150_ServerAuditSpecificationStatementTests150, ServerAuditSpecificationStatementTests150 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 21156b7 commit 227c7e5

8 files changed

Lines changed: 53 additions & 4 deletions

File tree

ast/server_audit_statement.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ type DropServerAuditStatement struct {
3333
func (s *DropServerAuditStatement) statement() {}
3434
func (s *DropServerAuditStatement) node() {}
3535

36+
// DropServerAuditSpecificationStatement represents a DROP SERVER AUDIT SPECIFICATION statement
37+
type DropServerAuditSpecificationStatement struct {
38+
Name *Identifier
39+
IsIfExists bool
40+
}
41+
42+
func (s *DropServerAuditSpecificationStatement) statement() {}
43+
func (s *DropServerAuditSpecificationStatement) node() {}
44+
3645
// AuditTarget represents the target of a server audit
3746
type AuditTarget struct {
3847
TargetKind string // File, ApplicationLog, SecurityLog

parser/marshal.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ func statementToJSON(stmt ast.Statement) jsonNode {
207207
return dropServerRoleStatementToJSON(s)
208208
case *ast.DropServerAuditStatement:
209209
return dropServerAuditStatementToJSON(s)
210+
case *ast.DropServerAuditSpecificationStatement:
211+
return dropServerAuditSpecificationStatementToJSON(s)
210212
case *ast.DropDatabaseAuditSpecificationStatement:
211213
return dropDatabaseAuditSpecificationStatementToJSON(s)
212214
case *ast.DropAvailabilityGroupStatement:
@@ -10308,6 +10310,17 @@ func dropServerAuditStatementToJSON(s *ast.DropServerAuditStatement) jsonNode {
1030810310
return node
1030910311
}
1031010312

10313+
func dropServerAuditSpecificationStatementToJSON(s *ast.DropServerAuditSpecificationStatement) jsonNode {
10314+
node := jsonNode{
10315+
"$type": "DropServerAuditSpecificationStatement",
10316+
"IsIfExists": s.IsIfExists,
10317+
}
10318+
if s.Name != nil {
10319+
node["Name"] = identifierToJSON(s.Name)
10320+
}
10321+
return node
10322+
}
10323+
1031110324
func dropDatabaseAuditSpecificationStatementToJSON(s *ast.DropDatabaseAuditSpecificationStatement) jsonNode {
1031210325
node := jsonNode{
1031310326
"$type": "DropDatabaseAuditSpecificationStatement",

parser/parse_ddl.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,17 @@ func (p *Parser) parseDropServerRoleStatement() (ast.Statement, error) {
10861086
return stmt, nil
10871087
case "AUDIT":
10881088
p.nextToken()
1089+
// Check if next token is SPECIFICATION
1090+
if strings.ToUpper(p.curTok.Literal) == "SPECIFICATION" {
1091+
p.nextToken()
1092+
stmt := &ast.DropServerAuditSpecificationStatement{}
1093+
stmt.Name = p.parseIdentifier()
1094+
// Skip optional semicolon
1095+
if p.curTok.Type == TokenSemicolon {
1096+
p.nextToken()
1097+
}
1098+
return stmt, nil
1099+
}
10891100
stmt := &ast.DropServerAuditStatement{}
10901101
stmt.Name = p.parseIdentifier()
10911102
// Skip optional semicolon

parser/parse_statements.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3796,6 +3796,22 @@ func convertAuditGroupName(name string) string {
37963796
"DATABASE_OBJECT_ACCESS_GROUP": "DatabaseObjectAccess",
37973797
"BATCH_COMPLETED_GROUP": "BatchCompletedGroup",
37983798
"BATCH_STARTED_GROUP": "BatchStartedGroup",
3799+
"SUCCESSFUL_LOGIN_GROUP": "SuccessfulLogin",
3800+
"LOGOUT_GROUP": "Logout",
3801+
"SERVER_STATE_CHANGE_GROUP": "ServerStateChange",
3802+
"FAILED_LOGIN_GROUP": "FailedLogin",
3803+
"LOGIN_CHANGE_PASSWORD_GROUP": "LoginChangePassword",
3804+
"SERVER_ROLE_MEMBER_CHANGE_GROUP": "ServerRoleMemberChange",
3805+
"SERVER_PRINCIPAL_IMPERSONATION_GROUP": "ServerPrincipalImpersonation",
3806+
"SERVER_OBJECT_OWNERSHIP_CHANGE_GROUP": "ServerObjectOwnershipChange",
3807+
"DATABASE_MIRRORING_LOGIN_GROUP": "DatabaseMirroringLogin",
3808+
"BROKER_LOGIN_GROUP": "BrokerLogin",
3809+
"SERVER_PERMISSION_CHANGE_GROUP": "ServerPermissionChange",
3810+
"SERVER_OBJECT_PERMISSION_CHANGE_GROUP": "ServerObjectPermissionChange",
3811+
"SERVER_OPERATION_GROUP": "ServerOperation",
3812+
"TRACE_CHANGE_GROUP": "TraceChange",
3813+
"SERVER_OBJECT_CHANGE_GROUP": "ServerObjectChange",
3814+
"SERVER_PRINCIPAL_CHANGE_GROUP": "ServerPrincipalChange",
37993815
}
38003816
if mapped, ok := groupMap[strings.ToUpper(name)]; ok {
38013817
return mapped
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"todo": true}
1+
{}

0 commit comments

Comments
 (0)