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

Devcert falsely decides that a domain is already part of a host file as long as the word appears within the file #28

Open
wessberg opened this issue Sep 9, 2018 · 0 comments

Comments

@wessberg
Copy link

wessberg commented Sep 9, 2018

In darwin.ts, the addDomainToHostFileIfMissing function will falsely decide that the provided domains name is already part of the hosts file if the word provided as domain occurs within the file. Here's an excerpt of the current code:

// Inside darwin.ts
 async addDomainToHostFileIfMissing(domain: string) {
    // This line only checks if the word appears within the file
    if (!hostsFileContents.includes(domain)) {
        // ...
    }
  }

This leads to plenty of false positives.
For example, consider this scenario:

We have a hosts file:

##
# Host Database
##
127.0.0.1 my-app.test

Now, we want to generate a certficate for just app.test. Because the hosts file already includes the string app.test, addDomainToHostFileIfMissing will decide that it is already included and skip adding the domain to the hosts file.

An example of a more robust solution would be to split the key-value pairs and perform strict equality checks between the two domain names

alias-mac pushed a commit to alias-mac/devcert that referenced this issue Feb 8, 2024
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

No branches or pull requests

1 participant