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

Truncate Text field value in default pretty reporter when needed #936

Closed
anderseknert opened this issue Jul 25, 2024 · 0 comments · Fixed by #937
Closed

Truncate Text field value in default pretty reporter when needed #936

anderseknert opened this issue Jul 25, 2024 · 0 comments · Fixed by #937
Labels
good first issue Good for newcomers

Comments

@anderseknert
Copy link
Member

When violations occur on some very long lines, the pretty reporter prints it in its entirety under the Text attribute. This can cause the terminal output to be wrapped, which makes everything look bad. The following screenshot demonstrates this:

Screenshot 2024-07-25 at 08 12 24

This is the rule that caused this. The wrapping however taints all violations, and not just the one that contained a long line.

We should truncate the output of the Text field to max 120 characters, as that's the default max line length recommendation.

Rule:         	rule-name-repeats-package                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               	
Description:  	Rule name repeats package                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               	
Category:     	style                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   	
Location:     	cloud-foundry/polices/pas/cert/certificate_test.rego:90:1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               	
Text:         	certChain = "-----BEGIN CERTIFICATE-----\nMIIESjCCAzKgAwIBAgIJAJpBvIaxZbsqMA0GCSqGSIb3DQEBCwUAMIGYMQswCQYD\nVQQGEwJVUzELMAkGA1UECAwCTlkxETAPBgNVBAcMCE5ldyBZb3JrMRQwEgYDVQQK\nDAtNaXR0ZW5zIE9yZzEWMBQGA1UECwwNTGFicyBQbGF0Zm9ybTEZMBcGA1UEAwwQ\nd2ViLmN1c3RvbWVyLm9yZzEgMB4GCSqGSIb3DQEJARYRZmFrZXlAbWNmYWtlcy5j\nb20wHhcNMTkwOTEzMTUxNjIxWhcNMTkxMDEzMTUxNjIxWjCBmDELMAkGA1UEBhMC\nVVMxCzAJBgNVBAgMAk5ZMREwDwYDVQQHDAhOZXcgWW9yazEUMBIGA1UECgwLTWl0\ndGVucyBPcmcxFjAUBgNVBAsMDUxhYnMgUGxhdGZvcm0xGTAXBgNVBAMMEHdlYi5j\ndXN0b21lci5vcmcxIDAeBgkqhkiG9w0BCQEWEWZha2V5QG1jZmFrZXMuY29tMIIB\nIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsr2TolHBt18D9ihtN+vvksLu\nv+O8qpfzSbpj6WdOSNCsUSQiCVOeZMChoq4Lm7e7WHruoCj/el7+FxW6To/OkJwh\nLSkfCBDYqqGq7AwTLuZ2/Hu/l93mqPkHGCQzYAu0R4NCh97uWa5PKdMqJKf7Bmrp\neMyLbsjEpImVw6hnEK7zllrzZDNLEXxhlakLw9TV2VfghMdo7TKqPYvnmzu/n+Zz\nwKK0FQbc0YJoka/tMm/qe1GOnTSNIr7vp+ovPGh46/VU36YiKAiKfbWn3X6EPqSu\nJabD55LBUQQRrrsLlKgoNOWbjyG73fJ8xd0/E8vtDyj9JgidfOikKcR33F/O/wID\nAQABo4GUMIGRMA4GA1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ZQU2WN/s/wP\nxph0pSfsfFsTKM4RhTWD2v4fgk+xZiKd1p0+L4hTtpwnEw0uXRVd0ki6muwV5y/P\n+5FHUeldq+pgTcgzuK8CAwEAAaMPMA0wCwYDVR0PBAQDAgLkMA0GCSqGSIb3DQEB\nBQUAA4GBAJiDAAtY0mQQeuxWdzLRzXmjvdSuL9GoyT3BF/jSnpxz5/58dba8pWen\nv3pj4P3w5DoOso0rzkZy2jEsEitlVM2mLSbQpMM+MUVQCQoiG6W9xuCFuxSrwPIS\npAqEAuV4DNoxQKKWmhVv+J0ptMWD25Pnpxeq5sXzghfJnslJlQND\n-----END CERTIFICATE-----\n"	
Documentation:	https://docs.styra.com/regal/rules/style/rule-name-repeats-package  
@anderseknert anderseknert added the good first issue Good for newcomers label Jul 25, 2024
charlieegan3 added a commit to charlieegan3/regal that referenced this issue Jul 25, 2024
Fixes StyraInc#936

Signed-off-by: Charlie Egan <charlie@styra.com>
anderseknert pushed a commit to charlieegan3/regal that referenced this issue Jul 25, 2024
Fixes StyraInc#936

Signed-off-by: Charlie Egan <charlie@styra.com>
anderseknert added a commit that referenced this issue Jul 29, 2024
Fixes #936

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this issue Jul 29, 2024
Fixes #936

Signed-off-by: Anders Eknert <anders@styra.com>
srenatus pushed a commit to srenatus/regal that referenced this issue Oct 1, 2024
* reporter: Trim long lines of location text

Fixes StyraInc#936

Signed-off-by: Charlie Egan <charlie@styra.com>

* reporter: Limit pretty lines at 120 chars instead

Signed-off-by: Charlie Egan <charlie@styra.com>

---------

Signed-off-by: Charlie Egan <charlie@styra.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant