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

Fix failing test for censys.ts #2428

Merged
merged 4 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions backend/src/tasks/censys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ export const handler = async (commandOptions: CommandOptions) => {
for (const hit of data.result.hits) {
if (!hit.names) continue;
for (const name of hit.names) {
if (name.endsWith(rootDomain) && !uniqueNames.has(name)) {
uniqueNames.add(name);
const normalizedName = name.replace(/\*\.|^(www\.)/g, ''); // Remove www from beginning of name and wildcards from entire name
if (
normalizedName.endsWith(rootDomain) &&
!uniqueNames.has(normalizedName)
) {
uniqueNames.add(normalizedName);
foundDomains.add({
name: name.replace('*.', ''),
name: normalizedName,
organization: { id: organizationId! },
fromRootDomain: rootDomain,
discoveredBy: { id: scanId }
Expand Down
17 changes: 16 additions & 1 deletion backend/src/tasks/test/__snapshots__/censys.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`censys basic test: helpers.saveDomainsToDb 1`] = `Array []`;
exports[`censys basic test: helpers.saveDomainsToDb 1`] = `
Array [
Domain {
"discoveredBy": Object {
"id": "ddf56d43-7f87-4139-9a86-b8a1ffde9b9e",
},
"fromRootDomain": "filedrop.cisa.gov",
"ip": "104.84.119.215",
"name": "filedrop.cisa.gov",
"organization": Object {
"id": "organizationId",
},
"subdomainSource": "censys",
},
]
`;
Loading
Loading