forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorganization-summary.js
More file actions
145 lines (137 loc) · 3.91 KB
/
organization-summary.js
File metadata and controls
145 lines (137 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import { GraphQLObjectType } from 'graphql'
import { categorizedSummaryType } from '../../summaries'
export const organizationSummaryType = new GraphQLObjectType({
name: 'OrganizationSummary',
description: 'Summaries based on domains that the organization has claimed.',
fields: () => ({
mail: {
type: categorizedSummaryType,
description:
'Summary based on mail scan results for a given organization.',
resolve: ({ mail }, _) => {
let percentPass, percentageFail
if (mail.total <= 0) {
percentPass = 0
percentageFail = 0
} else {
percentPass = Number(((mail.pass / mail.total) * 100).toFixed(1))
percentageFail = Number(((mail.fail / mail.total) * 100).toFixed(1))
}
const categories = [
{
name: 'pass',
count: mail.pass,
percentage: percentPass,
},
{
name: 'fail',
count: mail.fail,
percentage: percentageFail,
},
]
return {
categories,
total: mail.total,
}
},
},
web: {
type: categorizedSummaryType,
description:
'Summary based on web scan results for a given organization.',
resolve: ({ web }, _) => {
let percentPass, percentageFail
if (web.total <= 0) {
percentPass = 0
percentageFail = 0
} else {
percentPass = Number(((web.pass / web.total) * 100).toFixed(1))
percentageFail = Number(((web.fail / web.total) * 100).toFixed(1))
}
const categories = [
{
name: 'pass',
count: web.pass,
percentage: percentPass,
},
{
name: 'fail',
count: web.fail,
percentage: percentageFail,
},
]
return {
categories,
total: web.total,
}
},
},
dmarcPhase: {
type: categorizedSummaryType,
description: 'Summary based on DMARC phases for a given organization.',
resolve: ({ dmarc_phase }, _) => {
let percentNotImplemented,
percentAsses,
percentDeploy,
percentEnforce,
percentMaintain
if (dmarc_phase.total <= 0) {
percentNotImplemented = 0
percentAsses = 0
percentDeploy = 0
percentEnforce = 0
percentMaintain = 0
} else {
percentNotImplemented = Number(
((dmarc_phase.not_implemented / dmarc_phase.total) * 100).toFixed(
1,
),
)
percentAsses = Number(
((dmarc_phase.assess / dmarc_phase.total) * 100).toFixed(1),
)
percentDeploy = Number(
((dmarc_phase.deploy / dmarc_phase.total) * 100).toFixed(1),
)
percentEnforce = Number(
((dmarc_phase.enforce / dmarc_phase.total) * 100).toFixed(1),
)
percentMaintain = Number(
((dmarc_phase.maintain / dmarc_phase.total) * 100).toFixed(1),
)
}
const categories = [
{
name: 'not implemented',
count: dmarc_phase.not_implemented,
percentage: percentNotImplemented,
},
{
name: 'assess',
count: dmarc_phase.assess,
percentage: percentAsses,
},
{
name: 'deploy',
count: dmarc_phase.deploy,
percentage: percentDeploy,
},
{
name: 'enforce',
count: dmarc_phase.enforce,
percentage: percentEnforce,
},
{
name: 'maintain',
count: dmarc_phase.maintain,
percentage: percentMaintain,
},
]
return {
categories,
total: dmarc_phase.total,
}
},
},
}),
})