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

Implement WHOIS / registry info search page on get.gov #267

Closed
7 tasks done
gabydisarli opened this issue Jan 30, 2024 · 10 comments · May be fixed by #312
Closed
7 tasks done

Implement WHOIS / registry info search page on get.gov #267

gabydisarli opened this issue Jan 30, 2024 · 10 comments · May be fixed by #312
Assignees
Labels
carryover Carryover from a previous sprint dev For developers to work on

Comments

@gabydisarli
Copy link
Contributor

gabydisarli commented Jan 30, 2024

Story

A WHOIS search feature needs to be added on a new page in get.gov/domains/whois.

Updated Figma

Acceptance Criteria

Additional Context

The google doc for content is the source of truth for the content for this page

For devs:
You could use a package from online to help with whois as there are a few. However, if you don't find one that's reliable, you could send the whois message and either parse into a json or do string search to find the values that need to display at the top. Then show the full string output for the full whois section. While string search is not great, for a few values it may be reasonable to do if json seems to difficult.

While not many of these node packages for whois are well maintained, you could use their code as examples for writing your own as most are a single file for executing this function.

Note on difficulty, please keep prod team updated if blockers or issues arise that slow this down
Below is a 5 mins js function to retreive whois, this is just an example of how to get whois and retrieve the data as string without any third party dependencies. note net comes with node.

You may copy the below code into a .js, such as whois.js file then run "node whois.js" in terminal.

const net = require('net');
const domain = 'gsa.gov';

// Define the Cloudflare's WHOIS server
const whoisServer = 'whois.dotgov.gov';
function parseWhois(whoisString) {
    // super quick non elegant parsing 
    // Split the string into lines
    const lines = whoisString.split('\n');
    const result = {};
  
    // Iterate over each line
    lines.forEach(line => {
      // Check if the line contains a colon
      const colonIndex = line.indexOf(':');
      if (colonIndex !== -1) {
        // Extract the key and value, trim whitespace
        const key = line.substring(0, colonIndex).trim();
        const value = line.substring(colonIndex + 1).trim();
        // Add the key-value pair to the result object
        //missing here you need to handle multiple nameservers
        result[key] = value;

        //note this is quick and has bad parsing on << >> values
        //I also didn't convert to lower case, which should be done. 
        //This should just be serve as a quick an example
      }
    });
  
    return result;
  }
// Function to send WHOIS query
function sendWhoisQuery(domain, server, callback) {
    const client = net.createConnection({ port: 43, host: server }, () => {
        client.write(`${domain}\r\n`);
    });

    let whoisData = '';
    let whoisJson={}
    client.on('data', (data) => {
        whoisData += data.toString();
        //convert to json and just print here
        // in the real code you will want to return data as json so that you can access the values
        whoisJson =parseWhois(whoisData)
        console.log(JSON.stringify(whoisJson))
    });


    client.on('end', () => {
        callback(null, whoisData);
    });

    client.on('error', (err) => {
        callback(err);
    });
}

// Perform the WHOIS query
sendWhoisQuery(domain, whoisServer, (err, data) => {
    if (err) {
        console.error('Error:', err);
    } else {
       // totally complex way to just prove the whois shows as a string
        console.log('WHOIS data:', data);
    }
});

Issue Links

Design ticket: cisagov/manage.get.gov#1221

@vickyszuchin
Copy link

"refinement" label added: @abroddrick requested time to review the scope and ACs further before committing this into the sprint. It work may be too large for one sprint. It may need splitting. Currently, it has been story pointed to a 5.

Decision in sprint planning meeting is to keep this ticket in "Ready" until dev analysis is completed.

@h-m-f-t
Copy link
Member

h-m-f-t commented Jun 17, 2024

Product proposes punting out of 48. Moving to 49. @abroddrick

@erinysong erinysong self-assigned this Jul 2, 2024
@abroddrick
Copy link
Contributor

Note, this was decided to not be split due to not needing to investigate using a third party library as we can just do the parsing ourselves

@PaulKuykendall
Copy link

Nice job investigation, @erinysong. As we discussed in standup, WHOIS is really a legacy, text-based, service originally designed to be human readable. Of course, we have long made attempts to get machines to read this.

However, RDAP is create just for this very purpose, a RESTful protocol in JSON over HTTP.. :-) So this really looks like the right direction.

@vickyszuchin
Copy link

"Blocked" added: Erin needs guidance on how to proceed with this ticket @abroddrick

@erinysong
Copy link
Contributor

@abroddrick @h-m-f-t for context, I've been talking with Cloudflare reps + personally researching since there's incompatibilities with how WHOIS is called (via port 43 and server like the example node script) and get.gov (which is generated via HTML, a client-based language). Cloudflare has recommended using RDAP for querying domain data instead (summary: RDAP is a more modern standard expected to replace WHOIS and is built with more robust cross-platform use and data formatting). I'm also leaning towards RDAP after individual research but wanted to check if we have a specific reason for using WHOIS / if other services rely on it.

Slack thread with more details

@h-m-f-t
Copy link
Member

h-m-f-t commented Jul 13, 2024

More than happy for us to implement RDAP to complete this feature, @erinysong.

@vickyszuchin
Copy link

vickyszuchin commented Jul 15, 2024

@abroddrick I added the "blocked" label on this ticket until we make a final decision on how to proceed with this ticket. If we decide to switch to RAD, we should revisit and revise the ticket description and ACs accordingly. Or we can close this ticket and create a new one.
cc: @h-m-f-t @katypies

@abroddrick
Copy link
Contributor

This ticket wasn't meant to restrict how things should be implemented @vickyszuchin, just provide examples of how things may work. That said updating the AC would make sense. @erinysong what are your feelings on the level of difficulty of using RDAP instead? Will you get a returned value that is easy to parse? Lastly, have you tried this locally or been provided examples from those you talk to already to give you a starting base to go off of?

These questions are just to determine if we need to split things out of this ticket. We could go back to having a ticket for just getting and parsing the info we need (nameservers, etc) and then another ticket for making the UI to use it. Testing the first one would be rather difficult though I imagine since we have no real unit tests there and people would need to test by calling what ever functions were created from their local machine.

@abroddrick
Copy link
Contributor

closing as wont do as this is now covered in #316 and 2589

@abroddrick abroddrick closed this as not planned Won't fix, can't repro, duplicate, stale Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
carryover Carryover from a previous sprint dev For developers to work on
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

6 participants