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

Base64 strings should not be checked for typos #327

Closed
jplatte opened this issue Aug 4, 2021 · 5 comments · Fixed by #328
Closed

Base64 strings should not be checked for typos #327

jplatte opened this issue Aug 4, 2021 · 5 comments · Fixed by #328

Comments

@jplatte
Copy link
Contributor

jplatte commented Aug 4, 2021

I just got lots of errors for a base64-encoded TLS certificate. Typos should probably detect base64 strings and not check them, or just skip .pem files entirely :)

error: `UE` should be `USE`, `DUE`
  --> ./examples/self_signed_certs/cert.pem:3:14
  |
3 | BQAwWTELMAkGA1UEBhMCVVMxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
  |               ^^
  |
error: `UE` should be `USE`, `DUE`
  --> ./examples/self_signed_certs/cert.pem:4:42
  |
4 | GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDESMBAGA1UEAwwJbG9jYWxob3N0MB4X
  |                                           ^^
  |
error: `UE` should be `USE`, `DUE`
  --> ./examples/self_signed_certs/cert.pem:5:50
  |
5 | DTIxMDczMTE0MjIxMloXDTIyMDczMTE0MjIxMlowWTELMAkGA1UEBhMCVVMxEzAR
  |                                                   ^^
  |
error: `UE` should be `USE`, `DUE`
  --> ./examples/self_signed_certs/cert.pem:7:14
  |
7 | IEx0ZDESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  |               ^^
  |
error: `Fo` should be `Of`, `For`
  --> ./examples/self_signed_certs/cert.pem:14:36
   |
14 | NfS4LAYuKeWwHbzooER0yZ0wHwYDVR0jBBgwFoAUzFnKNfS4LAYuKeWwHbzooER0
   |                                     ^^
   |
@epage
Copy link
Collaborator

epage commented Aug 4, 2021

We have base64 detection; to understand why its not working in your case, I'd need to see the entire file.

You can work around this with per-file settings though if we have a known extension, I think its worth baking it directly into typos

@jplatte
Copy link
Contributor Author

jplatte commented Aug 4, 2021

This is the file: https://github.com/tokio-rs/axum/blob/7cf8dafdce26276b1969111dbbf034bb98786e30/examples/self_signed_certs/cert.pem

I used --exclude '*.pem' to exclude this file (and also the corresponding key.pem).

@jplatte
Copy link
Contributor Author

jplatte commented Aug 4, 2021

I guess base64 detection might not trigger on these lines because they happen to only contain alphanumeric characters?

@epage
Copy link
Collaborator

epage commented Aug 4, 2021

For our base64 detection to work, it needs to be 90+ characters and have the appropriate padding. The line splitting is what I think is messing up the detection.

I'm working on making all cert files excluded by default

epage added a commit to epage/typos that referenced this issue Aug 4, 2021
epage added a commit to epage/typos that referenced this issue Aug 4, 2021
@epage epage closed this as completed in #328 Aug 4, 2021
@epage
Copy link
Collaborator

epage commented Aug 4, 2021

Binaries for v1.1.5 should be building right now which should exclude cert file content by default.

I've added a cert file type (see typos --type-list). You can see this definition in the config and what it causes to happen by running typos --dump-config -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants