Repository navigation
Conversation
e6cac47 to
eb18754
Compare
|
@nikpivkin could you please review this bugfix as well? 🙏 |
|
#11662 is merged, but this branch still has its commits, so the diff has extra changes. Please rebase onto |
…keep orphan rules
eb18754 to
ac45435
Compare
|
@nikpivkin oh, yep, sorry, rebased this and #11663 |
nikpivkin
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
Rules without a known server go to the placeholder server with unmanaged metadata. AZU-0029 reads servers through database.all_servers, which skips unmanaged servers, so these rules are not reported. In ARM the server name is usually a parameter, so this is the common case for top-level rules. Not for this PR. AZU-0029 in trivy-checks should read rules from all servers, and we will do it separately.
nikpivkin
left a comment
There was a problem hiding this comment.
The description says AZU-0029 stays silent for these rules "as it does for orphan rules in Terraform". In Terraform such rules never reach the model, because GetReferencingResources does not find them. The result is the same but the reason is different, so I'd reword this part.
| } | ||
|
|
||
| // orphanage holds firewall rules whose server is unknown. | ||
| func orphanage(metadata iacTypes.Metadata, rules []database.FirewallRule) database.Server { |
There was a problem hiding this comment.
orphanage can create the unmanaged metadata itself, as orphanage in the storage adapter does. The wrapper does not need the same metadata as Server, so MySQL and MariaDB can drop the variable.
mysqlDbServers = append(mysqlDbServers, database.MySQLServer{
Metadata: iacTypes.NewUnmanagedMetadata(),
Server: orphanage(rules),
})MSSQL and PostgreSQL then keep a local metadata only for the wrapper and its own fields.
There was a problem hiding this comment.
orphanage now creates the unmanaged metadata, and MySQL and MariaDB build the wrapper inline, in 670e8ba.
| }, | ||
| }, | ||
| { | ||
| name: "firewall rules as child resources", |
There was a problem hiding this comment.
The tests have no MariaDB case. The code is shared, so one case with a nested rule is enough.
There was a problem hiding this comment.
Added a MariaDB server with a nested rule to the child resources case in 7b94476.
|
Reworded the description: it no longer compares with Terraform, and points to aquasecurity/trivy-checks#672. |
Description
The database adapter read only
properties.firewallRules, which isn't an ARM property of the server, so AVD-AZU-0029 never fired. Firewall rules are separate resources (Microsoft.Sql/servers/firewallRules, and the MySQL, MariaDB and PostgreSQL equivalents), declared as children or at the top level.Now each server gets its
firewallRuleschildren, nested or top-level with a<server name>/<rule name>name, throughGetChildResources. Theproperties.firewallRulesread is removed.A top-level rule whose name or server name is an expression goes to a server with unmanaged metadata of the same kind. AZU-0029 reads only managed servers, so it stays silent for these rules until aquasecurity/trivy-checks#672 makes it read rules from all servers.
Before and after, scanning the template from #11655 (
trivy config --skip-check-update .):Related issues
Checklist
🤖 Generated with Claude Code