Filter Misconfigurations

By Severity

Use --severity option.

  1. trivy conf --severity HIGH,CRITICAL examples/misconf/mixed

Result

  1. 2021-07-10T17:37:13.267+0300 INFO Detected config files: 4
  2. configs/Dockerfile (dockerfile)
  3. ===============================
  4. Tests: 23 (SUCCESSES: 21, FAILURES: 2, EXCEPTIONS: 0)
  5. Failures: 2 (HIGH: 1, CRITICAL: 0)
  6. +---------------------------+------------+----------------------+----------+------------------------------------------+
  7. | TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |
  8. +---------------------------+------------+----------------------+----------+------------------------------------------+
  9. | Dockerfile Security Check | DS002 | Image user is 'root' | HIGH | Specify at least 1 USER |
  10. | | | | | command in Dockerfile with |
  11. | | | | | non-root user as argument |
  12. | | | | | -->avd.aquasec.com/appshield/ds002 |
  13. +---------------------------+------------+----------------------+----------+------------------------------------------+
  14. configs/deployment.yaml (kubernetes)
  15. ====================================
  16. Tests: 28 (SUCCESSES: 14, FAILURES: 14, EXCEPTIONS: 0)
  17. Failures: 14 (HIGH: 1, CRITICAL: 0)
  18. +---------------------------+------------+-------------------------------------+----------+------------------------------------------+
  19. | TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |
  20. +---------------------------+------------+-------------------------------------+----------+------------------------------------------+
  21. | Kubernetes Security Check | KSV006 | docker.sock is mounted to container | HIGH | Deployment 'hello-kubernetes' should |
  22. | | | | | not specify '/var/run/docker.socker' in |
  23. | | | | | 'spec.template.volumes.hostPath.path' |
  24. | | | | | -->avd.aquasec.com/appshield/ksv006 |
  25. +---------------------------+------------+-------------------------------------+----------+------------------------------------------+
  26. configs/main.tf (terraform)
  27. ===========================
  28. Tests: 19 (SUCCESSES: 11, FAILURES: 8, EXCEPTIONS: 0)
  29. Failures: 8 (HIGH: 6, CRITICAL: 1)
  30. +------------------------------------------+------------+------------------------------------------+----------+--------------------------------------------------------+
  31. | TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |
  32. +------------------------------------------+------------+------------------------------------------+----------+--------------------------------------------------------+
  33. | Terraform Security Check powered by | AWS003 | AWS Classic resource usage. | HIGH | Resource |
  34. | tfsec | | | | 'aws_db_security_group.my-group' |
  35. | | | | | uses EC2 Classic. Use a VPC instead. |
  36. | | | | | -->tfsec.dev/docs/aws/AWS003/ |
  37. + +------------+------------------------------------------+----------+--------------------------------------------------------+
  38. | | AWS004 | Use of plain HTTP. | CRITICAL | Resource |
  39. | | | | | 'aws_alb_listener.my-alb-listener' |
  40. | | | | | uses plain HTTP instead of HTTPS. |
  41. | | | | | -->tfsec.dev/docs/aws/AWS004/ |
  42. + +------------+------------------------------------------+----------+--------------------------------------------------------+
  43. | | AWS018 | Missing description for security | HIGH | Resource |
  44. | | | group/security group rule. | | 'aws_security_group_rule.my-rule' should |
  45. | | | | | include a description for auditing |
  46. | | | | | purposes. -->tfsec.dev/docs/aws/AWS018/ |
  47. + +------------+------------------------------------------+ +--------------------------------------------------------+
  48. | | AWS025 | API Gateway domain name uses outdated | | Resource |
  49. | | | SSL/TLS protocols. | | 'aws_api_gateway_domain_name.empty_security_policy' |
  50. | | | | | defines outdated SSL/TLS policies (not using |
  51. | | | | | TLS_1_2). -->tfsec.dev/docs/aws/AWS025/ |
  52. + + + + +--------------------------------------------------------+
  53. | | | | | Resource |
  54. | | | | | 'aws_api_gateway_domain_name.missing_security_policy' |
  55. | | | | | should include security_policy (defauls to outdated |
  56. | | | | | SSL/TLS policy). -->tfsec.dev/docs/aws/AWS025/ |
  57. + + + + +--------------------------------------------------------+
  58. | | | | | Resource |
  59. | | | | | 'aws_api_gateway_domain_name.outdated_security_policy' |
  60. | | | | | defines outdated SSL/TLS policies (not using TLS_1_2). |
  61. | | | | | -->tfsec.dev/docs/aws/AWS025/ |
  62. + +------------+------------------------------------------+ +--------------------------------------------------------+
  63. | | AZU003 | Unencrypted managed disk. | | Resource 'azurerm_managed_disk.source' |
  64. | | | | | defines an unencrypted managed disk. |
  65. | | | | | -->tfsec.dev/docs/azure/AZU003/ |
  66. +------------------------------------------+------------+------------------------------------------+----------+--------------------------------------------------------+
  67. configs/variables.tf (terraform)
  68. ================================
  69. Tests: 1 (SUCCESSES: 1, FAILURES: 0, EXCEPTIONS: 0)
  70. Failures: 0 (HIGH: 0, CRITICAL: 0)

By Misconfiguration IDs

Use .trivyignore.

  1. $ cat .trivyignore
  2. # Accept the risk
  3. AWS003
  4. AWS018
  5. AWS025
  6. $ trivy conf --severity HIGH,CRITICAL examples/misconf/mixed

Result

  1. 2021-07-10T17:38:51.306+0300 INFO Detected config files: 4
  2. configs/Dockerfile (dockerfile)
  3. ===============================
  4. Tests: 23 (SUCCESSES: 21, FAILURES: 2, EXCEPTIONS: 0)
  5. Failures: 2 (HIGH: 1, CRITICAL: 0)
  6. +---------------------------+------------+----------------------+----------+------------------------------------------+
  7. | TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |
  8. +---------------------------+------------+----------------------+----------+------------------------------------------+
  9. | Dockerfile Security Check | DS002 | Image user is 'root' | HIGH | Specify at least 1 USER |
  10. | | | | | command in Dockerfile with |
  11. | | | | | non-root user as argument |
  12. | | | | | -->avd.aquasec.com/appshield/ds002 |
  13. +---------------------------+------------+----------------------+----------+------------------------------------------+
  14. configs/deployment.yaml (kubernetes)
  15. ====================================
  16. Tests: 28 (SUCCESSES: 14, FAILURES: 14, EXCEPTIONS: 0)
  17. Failures: 14 (HIGH: 1, CRITICAL: 0)
  18. +---------------------------+------------+-------------------------------------+----------+------------------------------------------+
  19. | TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |
  20. +---------------------------+------------+-------------------------------------+----------+------------------------------------------+
  21. | Kubernetes Security Check | KSV006 | docker.sock is mounted to container | HIGH | Deployment 'hello-kubernetes' should |
  22. | | | | | not specify '/var/run/docker.socker' in |
  23. | | | | | 'spec.template.volumes.hostPath.path' |
  24. | | | | | -->avd.aquasec.com/appshield/ksv006 |
  25. +---------------------------+------------+-------------------------------------+----------+------------------------------------------+
  26. configs/main.tf (terraform)
  27. ===========================
  28. Tests: 19 (SUCCESSES: 11, FAILURES: 8, EXCEPTIONS: 0)
  29. Failures: 8 (HIGH: 1, CRITICAL: 1)
  30. +------------------------------------------+------------+---------------------------+----------+------------------------------------------+
  31. | TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |
  32. +------------------------------------------+------------+---------------------------+----------+------------------------------------------+
  33. | Terraform Security Check powered by | AWS004 | Use of plain HTTP. | CRITICAL | Resource |
  34. | tfsec | | | | 'aws_alb_listener.my-alb-listener' |
  35. | | | | | uses plain HTTP instead of HTTPS. |
  36. | | | | | -->tfsec.dev/docs/aws/AWS004/ |
  37. + +------------+---------------------------+----------+------------------------------------------+
  38. | | AZU003 | Unencrypted managed disk. | HIGH | Resource 'azurerm_managed_disk.source' |
  39. | | | | | defines an unencrypted managed disk. |
  40. | | | | | -->tfsec.dev/docs/azure/AZU003/ |
  41. +------------------------------------------+------------+---------------------------+----------+------------------------------------------+
  42. configs/variables.tf (terraform)
  43. ================================
  44. Tests: 1 (SUCCESSES: 1, FAILURES: 0, EXCEPTIONS: 0)
  45. Failures: 0 (HIGH: 0, CRITICAL: 0)

By Exceptions

See Exceptions

Show Successes and Exceptions

Use --include-non-failures option to show successes and exceptions as well as failures.

  1. trivy conf --severity CRITICAL --include-non-failures examples/misconf/mixed

Result

  1. 2021-07-10T17:44:02.049+0300 INFO Detected config files: 4
  2. configs/Dockerfile (dockerfile)
  3. ===============================
  4. Tests: 23 (SUCCESSES: 21, FAILURES: 2, EXCEPTIONS: 0)
  5. Failures: 2 (CRITICAL: 0)
  6. +---------------------------+------------+------------------------------------------+----------+--------+-----------------+
  7. | TYPE | MISCONF ID | CHECK | SEVERITY | STATUS | MESSAGE |
  8. +---------------------------+------------+------------------------------------------+----------+--------+-----------------+
  9. | Dockerfile Security Check | DS006 | COPY '--from' refers to the current | CRITICAL | PASS | No issues found |
  10. | | | image | | | |
  11. + +------------+------------------------------------------+ + + +
  12. | | DS007 | Multiple ENTRYPOINT instructions are | | | |
  13. | | | listed | | | |
  14. + +------------+------------------------------------------+ + + +
  15. | | DS008 | Exposed port is out of range | | | |
  16. + +------------+------------------------------------------+ + + +
  17. | | DS010 | 'sudo' is used | | | |
  18. + +------------+------------------------------------------+ + + +
  19. | | DS011 | COPY with more than two arguments is not | | | |
  20. | | | ending with slash | | | |
  21. + +------------+------------------------------------------+ + + +
  22. | | DS012 | Duplicate aliases are defined in | | | |
  23. | | | different FROMs | | | |
  24. +---------------------------+------------+------------------------------------------+----------+--------+-----------------+
  25. ...