Skip to content

Commit 1b23ddd

Browse files
authored
Feature: filter domains by dmarc phase (#6814)
* add DMARC phases to filters in domain connection loaders * add dmarc phase enums * add dmarc phases to frontend filters * add DMARC Phase option to filter category dropdown * fix api tests * add dmarc phase to csv export option * translations * change phase keys to upper case to match new enums * simplify dmarc phase info access in stepper * add descriptions to dmarc phase enums * update translations
1 parent 8db0ff8 commit 1b23ddd

20 files changed

+366
-202
lines changed

api/src/domain/loaders/load-domain-connections-by-organizations-id.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ export const loadDomainConnectionsByOrgId =
390390
} else {
391391
domainFilters = aql`
392392
${domainFilters}
393-
FILTER POSITION( e.tags, ${filterValue}) ${comparison} true
393+
FILTER POSITION(e.tags, ${filterValue}) ${comparison} true
394394
`
395395
}
396396
} else if (filterCategory === 'asset-state') {
@@ -403,6 +403,11 @@ export const loadDomainConnectionsByOrgId =
403403
${domainFilters}
404404
FILTER POSITION(negativeTags, ${filterValue}) ${comparison} true
405405
`
406+
} else if (filterCategory === 'dmarc-phase') {
407+
domainFilters = aql`
408+
${domainFilters}
409+
FILTER v.phase ${comparison} ${filterValue}
410+
`
406411
}
407412
})
408413
}

api/src/domain/loaders/load-domain-connections-by-user-id.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,11 @@ export const loadDomainConnectionsByUserId =
415415
FILTER v.cveDetected ${comparison} true
416416
`
417417
}
418+
} else if (filterCategory === 'dmarc-phase') {
419+
domainFilters = aql`
420+
${domainFilters}
421+
FILTER v.phase ${comparison} ${filterValue}
422+
`
418423
}
419424
})
420425
}

api/src/domain/objects/__tests__/domain.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Domain, Selectors } from '../../../scalars'
1212
import englishMessages from '../../../locale/en/messages'
1313
import frenchMessages from '../../../locale/fr/messages'
1414
import { dnsScanConnection } from '../../../dns-scan'
15+
import { DmarcPhaseEnum } from '../../../enums'
1516

1617
describe('given the domain object', () => {
1718
describe('testing its field definitions', () => {
@@ -31,7 +32,7 @@ describe('given the domain object', () => {
3132
const demoType = domainType.getFields()
3233

3334
expect(demoType).toHaveProperty('dmarcPhase')
34-
expect(demoType.dmarcPhase.type).toMatchObject(GraphQLString)
35+
expect(demoType.dmarcPhase.type).toMatchObject(DmarcPhaseEnum)
3536
})
3637
it('has a hasDMARCReport field', () => {
3738
const demoType = domainType.getFields()

api/src/domain/objects/domain.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { GraphQLBoolean, GraphQLInt, GraphQLList, GraphQLNonNull, GraphQLObjectT
33
import { connectionArgs, globalIdField } from 'graphql-relay'
44

55
import { domainStatus } from './domain-status'
6-
import { AssetStateEnums, PeriodEnums } from '../../enums'
6+
import { AssetStateEnums, PeriodEnums, DmarcPhaseEnum } from '../../enums'
77
import { nodeInterface } from '../../node'
88
import { CveID, Domain, Selectors, Year } from '../../scalars'
99
import { dmarcSummaryType } from '../../dmarc-summaries/objects'
@@ -28,7 +28,7 @@ export const domainType = new GraphQLObjectType({
2828
resolve: ({ domain }) => domain,
2929
},
3030
dmarcPhase: {
31-
type: GraphQLString,
31+
type: DmarcPhaseEnum,
3232
description: 'The current dmarc phase the domain is compliant to.',
3333
resolve: ({ phase }) => phase,
3434
},

api/src/enums/dmarc-phase.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { GraphQLEnumType } from 'graphql'
2+
3+
export const DmarcPhaseEnum = new GraphQLEnumType({
4+
name: 'DmarcPhaseEnum',
5+
description: 'Phases of DMARC implementation.',
6+
values: {
7+
ASSESS: {
8+
value: 'assess',
9+
description: 'Assess domains and DMARC status.',
10+
},
11+
DEPLOY: {
12+
value: 'deploy',
13+
description: 'Deploy SPF and DKIM records.',
14+
},
15+
ENFORCE: {
16+
value: 'enforce',
17+
description: 'Enforce DMARC policies.',
18+
},
19+
MAINTAIN: {
20+
value: 'maintain',
21+
description: 'Maintain DMARC and update records.',
22+
},
23+
},
24+
})

api/src/enums/domain-filter-category.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@ export const DomainFilterCategory = new GraphQLEnumType({
2121
value: 'guidance-tag',
2222
description: 'Scanner findings.',
2323
},
24+
DMARC_PHASE: {
25+
value: 'dmarc-phase',
26+
description: 'DMARC phase.',
27+
},
2428
},
2529
})

api/src/enums/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ export * from './web-order-field'
3232
export * from './tag-ownership'
3333
export * from './system-filter-value'
3434
export * from './domain-filter-category'
35+
export * from './dmarc-phase'

api/src/enums/system-filter-value.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import { GraphQLEnumType } from 'graphql'
22
import { StatusEnum } from './status'
33
import { DomainTagLabel } from './domain-tag-label'
44
import { AssetStateEnums } from './asset-state'
5+
import { DmarcPhaseEnum } from './dmarc-phase'
6+
7+
const getEnumValues = (enums) => {
8+
return enums.getValues().reduce((acc, { name, value, description }) => {
9+
acc[name] = { value, description }
10+
return acc
11+
}, {})
12+
}
513

614
export const filterEnum = new GraphQLEnumType({
715
name: 'SystemFilterValue',
816
values: {
9-
...StatusEnum.getValues().reduce((acc, { name, value, description }) => {
10-
acc[name] = { value, description }
11-
return acc
12-
}, {}),
13-
...DomainTagLabel.getValues().reduce((acc, { name, value, description }) => {
14-
acc[name] = { value, description }
15-
return acc
16-
}, {}),
17-
...AssetStateEnums.getValues().reduce((acc, { name, value, description }) => {
18-
acc[name] = { value, description }
19-
return acc
20-
}, {}),
17+
...getEnumValues(StatusEnum),
18+
...getEnumValues(DomainTagLabel),
19+
...getEnumValues(AssetStateEnums),
20+
...getEnumValues(DmarcPhaseEnum),
2121
},
2222
description: 'Filter value from system-defined statuses or tags.',
2323
})

api/src/locale/en/messages.po

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ msgstr "`{argSet}` on the `VerifiedDomain` connection cannot be less than zero."
123123
msgid "`{argSet}` on the `VerifiedOrganization` connection cannot be less than zero."
124124
msgstr "`{argSet}` on the `VerifiedOrganization` connection cannot be less than zero."
125125

126+
#: src/organization/objects/organization.js:244
127+
#: src/organization/queries/get-all-organization-domain-statuses.js:69
128+
msgid "Assess"
129+
msgstr "Assess"
130+
126131
#: src/auth/check-permission.js:18
127132
#: src/auth/check-permission.js:57
128133
#: src/auth/user-required.js:10
@@ -135,7 +140,7 @@ msgstr "Authentication error. Please sign in."
135140
msgid "Cannot query additional findings without permission."
136141
msgstr "Cannot query additional findings without permission."
137142

138-
#: src/organization/objects/organization.js:359
143+
#: src/organization/objects/organization.js:378
139144
msgid "Cannot query affiliations on organization without admin permission or higher."
140145
msgstr "Cannot query affiliations on organization without admin permission or higher."
141146

@@ -165,12 +170,22 @@ msgstr "CVE is already ignored for this domain."
165170
msgid "CVE is not ignored for this domain."
166171
msgstr "CVE is not ignored for this domain."
167172

173+
#: src/organization/objects/organization.js:246
174+
#: src/organization/queries/get-all-organization-domain-statuses.js:71
175+
msgid "Deploy"
176+
msgstr "Deploy"
177+
168178
#: src/user/mutations/sign-up.js:111
169179
msgid "Email already in use."
170180
msgstr "Email already in use."
171181

172-
#: src/domain/mutations/request-scan.js:88
173-
#: src/domain/mutations/request-scan.js:98
182+
#: src/organization/objects/organization.js:248
183+
#: src/organization/queries/get-all-organization-domain-statuses.js:73
184+
msgid "Enforce"
185+
msgstr "Enforce"
186+
187+
#: src/domain/mutations/request-scan.js:89
188+
#: src/domain/mutations/request-scan.js:99
174189
msgid "Error while requesting scan. Please try again."
175190
msgstr "Error while requesting scan. Please try again."
176191

@@ -201,6 +216,11 @@ msgstr "Incorrect username or password. Please try again."
201216
msgid "Invalid token, please sign in."
202217
msgstr "Invalid token, please sign in."
203218

219+
#: src/organization/objects/organization.js:250
220+
#: src/organization/queries/get-all-organization-domain-statuses.js:75
221+
msgid "Maintain"
222+
msgstr "Maintain"
223+
204224
#: src/user/mutations/dismiss-message.js:75
205225
msgid "Message dismissed successfully"
206226
msgstr "Message dismissed successfully"
@@ -419,7 +439,7 @@ msgstr "Permission Denied: Please contact organization admin for help with user
419439
msgid "Permission Denied: Please contact organization admin for help with user role changes."
420440
msgstr "Permission Denied: Please contact organization admin for help with user role changes."
421441

422-
#: src/domain/mutations/create-domain.js:120
442+
#: src/domain/mutations/create-domain.js:121
423443
msgid "Permission Denied: Please contact organization user for help with creating domain."
424444
msgstr "Permission Denied: Please contact organization user for help with creating domain."
425445

@@ -432,12 +452,12 @@ msgstr "Permission Denied: Please contact organization user for help with creati
432452
#~ msgstr "Permission Denied: Please contact organization user for help with retrieving tags."
433453

434454
#: src/domain/queries/find-domain-by-domain.js:51
435-
#: src/organization/objects/organization.js:194
455+
#: src/organization/objects/organization.js:198
436456
msgid "Permission Denied: Please contact organization user for help with retrieving this domain."
437457
msgstr "Permission Denied: Please contact organization user for help with retrieving this domain."
438458

439459
#: src/domain/mutations/request-discovery.js:98
440-
#: src/domain/mutations/request-scan.js:64
460+
#: src/domain/mutations/request-scan.js:65
441461
msgid "Permission Denied: Please contact organization user for help with scanning this domain."
442462
msgstr "Permission Denied: Please contact organization user for help with scanning this domain."
443463

@@ -607,7 +627,7 @@ msgstr "Successfully archived organization: {0}."
607627
msgid "Successfully closed account."
608628
msgstr "Successfully closed account."
609629

610-
#: src/domain/mutations/request-scan.js:167
630+
#: src/domain/mutations/request-scan.js:174
611631
msgid "Successfully dispatched one time scan."
612632
msgstr "Successfully dispatched one time scan."
613633

@@ -778,20 +798,20 @@ msgstr "Unable to close account. Please try again."
778798
msgid "Unable to confirm completion of the tour. Please try again."
779799
msgstr "Unable to confirm completion of the tour. Please try again."
780800

781-
#: src/domain/mutations/create-domain.js:106
801+
#: src/domain/mutations/create-domain.js:107
782802
msgid "Unable to create domain in unknown organization."
783803
msgstr "Unable to create domain in unknown organization."
784804

785-
#: src/domain/mutations/create-domain.js:177
805+
#: src/domain/mutations/create-domain.js:178
786806
msgid "Unable to create domain, organization has already claimed it."
787807
msgstr "Unable to create domain, organization has already claimed it."
788808

789-
#: src/domain/mutations/create-domain.js:159
790-
#: src/domain/mutations/create-domain.js:167
791-
#: src/domain/mutations/create-domain.js:199
792-
#: src/domain/mutations/create-domain.js:208
793-
#: src/domain/mutations/create-domain.js:228
794-
#: src/domain/mutations/create-domain.js:236
809+
#: src/domain/mutations/create-domain.js:160
810+
#: src/domain/mutations/create-domain.js:168
811+
#: src/domain/mutations/create-domain.js:200
812+
#: src/domain/mutations/create-domain.js:209
813+
#: src/domain/mutations/create-domain.js:229
814+
#: src/domain/mutations/create-domain.js:237
795815
msgid "Unable to create domain. Please try again."
796816
msgstr "Unable to create domain. Please try again."
797817

@@ -833,8 +853,8 @@ msgstr "Unable to dismiss message. Please try again."
833853
#~ msgid "Unable to dispatch one time scan. Please try again."
834854
#~ msgstr "Unable to dispatch one time scan. Please try again."
835855

836-
#: src/organization/objects/organization.js:256
837-
#: src/organization/objects/organization.js:266
856+
#: src/organization/objects/organization.js:275
857+
#: src/organization/objects/organization.js:285
838858
msgid "Unable to export organization. Please try again."
839859
msgstr "Unable to export organization. Please try again."
840860

@@ -1008,8 +1028,8 @@ msgstr "Unable to load Aggregate guidance tag(s). Please try again."
10081028
#~ msgid "Unable to load all organization domain statuses. Please try again."
10091029
#~ msgstr "Unable to load all organization domain statuses. Please try again."
10101030

1011-
#: src/summaries/loaders/load-chart-summaries-by-period.js:47
1012-
#: src/summaries/loaders/load-chart-summaries-by-period.js:57
1031+
#: src/summaries/loaders/load-chart-summaries-by-period.js:50
1032+
#: src/summaries/loaders/load-chart-summaries-by-period.js:60
10131033
msgid "Unable to load chart summary data. Please try again."
10141034
msgstr "Unable to load chart summary data. Please try again."
10151035

@@ -1049,7 +1069,7 @@ msgstr "Unable to load DMARC failure data. Please try again."
10491069
msgid "Unable to load DMARC guidance tag(s). Please try again."
10501070
msgstr "Unable to load DMARC guidance tag(s). Please try again."
10511071

1052-
#: src/summaries/queries/dmarc-phase-summary.js:14
1072+
#: src/summaries/queries/dmarc-phase-summary.js:12
10531073
msgid "Unable to load DMARC phase summary. Please try again."
10541074
msgstr "Unable to load DMARC phase summary. Please try again."
10551075

@@ -1090,9 +1110,9 @@ msgstr "Unable to load domain selector(s). Please try again."
10901110
msgid "Unable to load domain. Please try again."
10911111
msgstr "Unable to load domain. Please try again."
10921112

1093-
#: src/domain/loaders/load-domain-connections-by-organizations-id.js:518
1094-
#: src/domain/loaders/load-domain-connections-by-organizations-id.js:528
1095-
#: src/domain/loaders/load-domain-connections-by-user-id.js:570
1113+
#: src/domain/loaders/load-domain-connections-by-organizations-id.js:523
1114+
#: src/domain/loaders/load-domain-connections-by-organizations-id.js:533
1115+
#: src/domain/loaders/load-domain-connections-by-user-id.js:575
10961116
#: src/user/loaders/load-my-tracker-by-user-id.js:33
10971117
msgid "Unable to load domain(s). Please try again."
10981118
msgstr "Unable to load domain(s). Please try again."
@@ -1137,8 +1157,8 @@ msgid "Unable to load mail summary. Please try again."
11371157
msgstr "Unable to load mail summary. Please try again."
11381158

11391159
#: src/additional-findings/loaders/load-top-25-reports.js:29
1140-
#: src/organization/loaders/load-all-organization-domain-statuses.js:158
1141-
#: src/organization/loaders/load-organization-domain-statuses.js:160
1160+
#: src/organization/loaders/load-all-organization-domain-statuses.js:164
1161+
#: src/organization/loaders/load-organization-domain-statuses.js:166
11421162
msgid "Unable to load organization domain statuses. Please try again."
11431163
msgstr "Unable to load organization domain statuses. Please try again."
11441164

@@ -1266,7 +1286,7 @@ msgstr "Unable to load web summary. Please try again."
12661286
msgid "Unable to query affiliation(s). Please try again."
12671287
msgstr "Unable to query affiliation(s). Please try again."
12681288

1269-
#: src/domain/loaders/load-domain-connections-by-user-id.js:560
1289+
#: src/domain/loaders/load-domain-connections-by-user-id.js:565
12701290
#: src/user/loaders/load-my-tracker-by-user-id.js:23
12711291
msgid "Unable to query domain(s). Please try again."
12721292
msgstr "Unable to query domain(s). Please try again."
@@ -1367,15 +1387,15 @@ msgstr "Unable to remove user from this organization. Please try again."
13671387
msgid "Unable to remove user from unknown organization."
13681388
msgstr "Unable to remove user from unknown organization."
13691389

1370-
#: src/domain/mutations/request-scan.js:118
1390+
#: src/domain/mutations/request-scan.js:119
13711391
msgid "Unable to request a one time scan on a domain that already has a pending scan."
13721392
msgstr "Unable to request a one time scan on a domain that already has a pending scan."
13731393

1374-
#: src/domain/mutations/request-scan.js:53
1394+
#: src/domain/mutations/request-scan.js:54
13751395
msgid "Unable to request a one time scan on an unknown domain."
13761396
msgstr "Unable to request a one time scan on an unknown domain."
13771397

1378-
#: src/domain/mutations/request-scan.js:126
1398+
#: src/domain/mutations/request-scan.js:127
13791399
msgid "Unable to request a one time scan. Please try again."
13801400
msgstr "Unable to request a one time scan. Please try again."
13811401

@@ -1864,9 +1884,9 @@ msgid "You must provide at most one pagination method (`before`, `after`, `offse
18641884
msgstr "You must provide at most one pagination method (`before`, `after`, `offset`) value to properly paginate the `web` connection."
18651885

18661886
#: src/summaries/loaders/load-chart-summaries-by-period.js:13
1867-
msgid "You must provide both `startDate` and `endDate` values to access the `ChartSummaries` connection."
1868-
msgstr "You must provide both `startDate` and `endDate` values to access the `ChartSummaries` connection."
1887+
#~ msgid "You must provide both `startDate` and `endDate` values to access the `ChartSummaries` connection."
1888+
#~ msgstr "You must provide both `startDate` and `endDate` values to access the `ChartSummaries` connection."
18691889

18701890
#: src/organization/loaders/load-organization-summaries-by-period.js:13
1871-
msgid "You must provide both `startDate` and `endDate` values to access the `OrganizationSummaries` connection."
1872-
msgstr "You must provide both `startDate` and `endDate` values to access the `OrganizationSummaries` connection."
1891+
#~ msgid "You must provide both `startDate` and `endDate` values to access the `OrganizationSummaries` connection."
1892+
#~ msgstr "You must provide both `startDate` and `endDate` values to access the `OrganizationSummaries` connection."

0 commit comments

Comments
 (0)