-
Notifications
You must be signed in to change notification settings - Fork 1
/
Code.gs
1416 lines (1079 loc) · 50.2 KB
/
Code.gs
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
*
* Maintain this script with github.com/gsa/marketplace-fedramp-gov-data
*
* In "Project Settings" (gear icon to left), maintain the script properties variable for the account publishing updates.
*
*/
/**
* In order to protect itself from humans adding/updating/reordering/removing sheets and their columns
* this script validates each sheet and their columns before processing. The errSheet and errArray
* help eliminate repetitive error messages.
*/
var errSheet = "";
var errArr = [];
/**
* Using a regular expression to scrub data into html class names (used to filter
* list data on the /products, /agencies, and /assessors pages). Some strings contain
* characters that are not allowed in class names.
*
* /[\W_]+/g:
* / = regex change delimiter.
* [] = Set of characters to match.
* \W = Any "non-word" character, opposite of [^a-zA-z0-9_]
* _ = Also match on _ to keep consistent.
* + = Match previous character(s) one-many times.
* /g = Global. Do for entire string (don't return after first occurance).
*/
const REGEX_NON_WORDS = /[\W_]+/g;
const REGEX_EXCESSIVE_SPACE = /\s/g;
/**
* Using a regular expression to scrub eastern time zone dates 4am/5am because this spreadsheet
* is in Eastern Time and dates are being created with times, causing them to be
* displayed differently for west coast.
* 2013-05-01T04:00:00.000Z would be 5/1 in Eastern Time (UTC-4), but 4/30 in Pacific Time (UTC-7)
*/
const REGEX_TIME_ZONE = /T0[0-9]:00:00.000Z/g;
const REPLACEMENT_TIME_ZONE = "T20:00:00.000Z";
/**
* Sheet names go here here. Add new sheet names and their columns to isValidSetup() function.
*/
const MASTER_AUTHORIZATION_STATUS_SHEET = "Master Authorization Status";
const MASTER_AGENCY_TAB_SHEET = "Master Agency Tab";
const MASTER_3PAO_LIST_SHEET = "Master 3PAO List";
const INITIAL_ATOS_SHEET = "Initial ATOs";
const REUSE_ATOS_SHEET = "Reuse ATOs";
const METRICS_SHEET = "Metrics";
/**
* Arrays of sheet columns for each sheet above
*/
const MASTER_AUTHORIZATION_STATUS_HEADERS = ["FR ID#", "CSP", "CSO", "Service Model", "Authorization Path", "Deployment Model", "Impact Level", "UEI Number", "Current 3PAO ID", "Security Contact Email", "Sales Contact Email", "Small Business?", "Logo URL", "CSP Website", "CSO Description", "CSP Business Function", "Additional Information", "In Process Initial Authorization Agency ID", "In Process Initial Sub Agency ID", "Current Active Status?", "FR Ready Active?", "FRR Most Recent Date", "In Process JAB Review Active?", "In Process JAB Review Most Recent Date", "In Process Program Review Active?", "In Process Program Review Most Recent Date", "In Process Program Review 2 Active?", "In Process Program Review 2 Most Recent Date", "In Process Agency Review Active?", "In Process Agency Review Most Recent Date", "FedRAMP In Process PMO Review Active?", "FedRAMP In Process PMO Review Most Recent Date", "FedRAMP Authorized Active?", "Non-Recent Authorized Services", "Recently Updated Authorized Services", "Authorizations", "Reuse", "Agency Authorizations", "Reuse Agencies", "Leveraged Systems", "Annual Assessment"];
const MASTER_AGENCY_TAB_HEADERS = ["Agency ID", "Agency Name", "Sub Agency", "E-mail", "Logo URL", "Website", "Authorizations", "Authorizations Number", "Reuse", "Reuse Number", "In Process (Agency Review)", "In Process (FedRAMP Review)","In Process (JAB Review)"];
const MASTER_3PAO_LIST_HEADERS = ["3PAO ID#", "Cert #", "3PAO Name", "POC Name", "POC Email", "Date Applied", "A2LA Accreditation Date", "FedRAMP Accreditation Date", "Logo URL", "Year Company Founded", "Website URL", "Primary Office Locations", "Description of 3PAO Services", "Consulting Services?", "Description of Consulting Services", "Additional Cyber Frameworks Your Company Is Accredited to Perform", "Active?", "CSPs providing consulting service to", "Current Clients", "Products Assessing (Number)"];
const INITIAL_ATOS_HEADERS = ["FR ID#", "Initial Authorization Agency ID", "Agency Name (Keep Hidden)", "Sub Agency ID", "Sub Agency Name (Keep hidden)", "Actual Authorizing Agency (keep hidden)", "Actual Reusing Agency Name (keep hidden)", "Agency ATO Date", "Authorization Date", "ATO Expiration", "Annual Assessment Date", "Authorizing Official", "Agency POC Email(s)", "Active?", "Comments (include all AA change dates)", "Authorization Year", "Authorization Path", "Authorization Timeline (in Days)"];
const REUSE_ATOS_HEADERS = ["FR ID", "Agency (Keep Hidden)", "Agency ID #", "Sub Agency Name (Keep hidden)", "Sub Agency #", "Actual Reusing Agency Name (keep hidden)", "Actual Reusing Agency (keep hidden)", "Agency Authorization", "Authorization Logged Date", "ATO Expiration", "AO", "Agency POC Email(s)", "Active?"];
const METRICS_HEADERS = ["FR ID", "Reuse ATOs", "Total ATOs", "Indirect Reuse", "ATOs", "Direct Reuse", "Total ATOs", "Indirect Reuse", "Ready", "In Process", "Authorizations"];
/**
* Constants helping the "Metrics" "latest" list. These constants are used to help eliminate unset dates.
*/
const NO_FRR = "No FRR Date";
const NO_JAB = "Not Active";
const NO_PROG = "Not Active";
const NO_AGENCY = "Not Active";
const NO_PMO = "Not In Process";
const NO_AUTH = "Not Authorized";
const STATUS_FRR = "Now FedRAMP Ready";
const STATUS_JAB = "Now in JAB Review";
const STATUS_PROG = "Now in Program Review";
const STATUS_AGENCY = "Now in Agency Review";
const STATUS_PMO = "Now in PMO Review";
const STATUS_AUTH = "Now Authorized";
// ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
const STRING_80_BYTES = " ";
/***************************************************************************************************/
/**
* GitHub personal access token (https://github.com/blog/1509-personal-api-tokens)
*/
const github = {
'owner': 'GSA',
'repo': 'marketplace-fedramp-gov-data',
'path': PropertiesService.getScriptProperties().getProperty('GIT_FILENAME'),
'branch': 'master',
'accessToken': PropertiesService.getScriptProperties().getProperty('GIT_ACCESS_TOKEN'),
'commitMessage': Utilities.formatString('Published on %s', Utilities.formatDate(new Date(), 'America/New_York', 'yyyy-MM-dd HH:mm:ss'))
};
/***************************************************************************************************/
/**
*
*/
function main() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
if(isValidSetup(ss) == false) {
return;
}
// Create json, retrieve sha, update github
updateGitHubRepo(getGitHubSha(), createJson(ss).replace(REGEX_TIME_ZONE,REPLACEMENT_TIME_ZONE));
}
/***************************************************************************************************/
/**
*
*
*/
function createJson(ss) {
l("Building JSON...");
var json = {
meta: {
last_change: Utilities.formatDate(new Date(), 'America/New_York', 'yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\''),
produced_by: "General Services Administration"
},
data: {
"Metrics": {
ready: "",
in_process: "",
total: "",
latest: []
},
"Filters": {
"product": {},
"agency": {},
"assessor":{}
},
"Products": [],
"Agencies": [],
"Assessors": [],
"AtoMapping": [],
"ReuseMapping": []
}
}
/**
* Metrics
*
* Note: "latest" metric built as part of "products"
*
*/
l(" Metrics");
initErrorCols(METRICS_SHEET);
var metricsVals = ss.getSheetByName(METRICS_SHEET).getDataRange().getValues();
json.data.Metrics.ready = metricsVals[1][getCol(METRICS_HEADERS, "Ready")];
json.data.Metrics.in_process = metricsVals[1][getCol(METRICS_HEADERS, "In Process")];
json.data.Metrics.total = metricsVals[1][getCol(METRICS_HEADERS, "Authorizations")];
/***************************************************************************************************/
/**
* Master Authorization Status
*/
var product = {
filter_classes: String,
id: String,
name: String,
csp: String,
cso: String,
logo: String,
service_offering: String,
status: String,
authorization: String,
reuse: String,
ready_status: String,
ready_date: String,
ip_jab_status: String,
ip_jab_date: String,
ip_prog_status: String,
ip_prog_date: String,
ip_prog_date2: String,
ip_agency_status: String,
ip_agency_date: String,
ip_pmo_status: String,
ip_pmo_date: String,
auth_date: String,
auth_type: String,
fedramp_ready: String,
partnering_agency: String,
fedramp_auth: String,
annual_assessment: String,
independent_assessor: String,
service_model: [],
deployment_model: String,
impact_level: String,
leveraged_systems: String,
agency_authorizations: [],
agency_reuse: [],
service_desc: String,
fedramp_msg: String,
sales_email: String,
security_email: String,
website: String,
uei: String,
small_business: String,
business_function: [],
service_last_90: [],
all_others: []
}
l(" Products");
initErrorCols(MASTER_AUTHORIZATION_STATUS_SHEET);
var workLatest;
var workArr = [];
var masterAuthVals = ss.getSheetByName(MASTER_AUTHORIZATION_STATUS_SHEET).getDataRange().getValues();
/**
* Loop through values on this tab, filling fields. Special processing generally happens at the bottom of the loop.
*/
for(var i = 1; i < masterAuthVals.length; i++) {
if(masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "FR ID#")] == "" ||
masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "CSP")] == "" ||
masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Current Active Status?")] == "No Status Found") {
continue;
}
product = {};
product.id = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "FR ID#")];
product.name = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "CSP")];
product.csp = product.name; // To utilize sort
product.cso = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "CSO")];
product.logo = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Logo URL")];
product.service_offering = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "CSO")];
product.status = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Current Active Status?")];
product.authorization = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Authorizations")];
product.reuse = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Reuse")];
product.ready_status = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "FR Ready Active?")];
product.ready_date = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "FRR Most Recent Date")];
product.ip_jab_status = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "In Process JAB Review Active?")];
product.ip_jab_date = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "In Process JAB Review Most Recent Date")];
product.ip_prog_status = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "In Process Program Review Active?")];
product.ip_prog_date = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "In Process Program Review Most Recent Date")];
product.ip_prog_date2 = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "In Process Program Review 2 Most Recent Date")];
product.ip_agency_status = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "In Process Agency Review Active?")];
product.ip_agency_date = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "In Process Agency Review Most Recent Date")];
product.ip_pmo_status = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "FedRAMP In Process PMO Review Active?")];
product.ip_pmo_date = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "FedRAMP In Process PMO Review Most Recent Date")];
product.auth_date = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "FedRAMP Authorized Active?")];
product.auth_type = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Authorization Path")];
product.fedramp_ready = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "FRR Most Recent Date")];
product.partnering_agency = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "In Process Initial Authorization Agency ID")];
if(masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "In Process Initial Sub Agency ID")] != "" ) {
product.partnering_agency = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "In Process Initial Sub Agency ID")];
}
product.fedramp_auth = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "FedRAMP Authorized Active?")];
product.annual_assessment = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Annual Assessment")];
product.independent_assessor = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Current 3PAO ID")];
product.service_model = Array.from(new Set(masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Service Model")].split("|"))).sort();
product.deployment_model = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Deployment Model")];
product.impact_level = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Impact Level")];
product.impact_level_number = getImpactLevelNumber(product.impact_level);
// Build and sort before storing
workArr = getItems(masterAuthVals, Array.from(new Set(masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Leveraged Systems")].split("|"))));
product.leveraged_systems = quickSortOnObjectCSP(workArr, 0, workArr.length-1);
// Force array into Set() to dedup, then sort before storing
product.agency_authorizations = Array.from(new Set(masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Agency Authorizations")].split("|"))).sort();
// Force array into Set() to dedup, then sort before storing
product.agency_reuse = Array.from(new Set(masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Reuse Agencies")].split("|"))).sort();
product.service_desc = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "CSO Description")];
product.fedramp_msg = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Additional Information")];
product.sales_email = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Sales Contact Email")];
product.security_email = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Security Contact Email")];
product.website = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "CSP Website")];
product.uei = masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "UEI Number")];
product.small_business = getYesNo(masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Small Business?")]);
product.business_function = Array.from(new Set(masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "CSP Business Function")].split("|"))).sort();
product.service_last_90 = Array.from(new Set(masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Recently Updated Authorized Services")].split("|"))).sort();
product.all_others = Array.from(new Set(masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Non-Recent Authorized Services")].split("|"))).sort();
/**
* Special processing for finding the 3 "latest" dates from all the below columns.
*/
workLatest = getLatest(product.id, product.logo, product.service_offering,
masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "FRR Most Recent Date")],
masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "In Process JAB Review Most Recent Date")],
masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "In Process Program Review Most Recent Date")],
masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "In Process Agency Review Most Recent Date")],
masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "FedRAMP In Process PMO Review Most Recent Date")],
masterAuthVals[i][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "FedRAMP Authorized Active?")]);
if(workLatest.date != "") { // If there's a good date in any of the above columns...
json.data.Metrics.latest.push(workLatest); // Build array of "latest" objects to be paired down later.
}
// Filter classes
product.filter_classes = "";
product.filter_classes += " filter-status-" + product.status.replace(REGEX_NON_WORDS,"-");
product.filter_classes += " filter-impact-level-" + product.impact_level.replace(REGEX_NON_WORDS,"-");
product.filter_classes += " filter-auth-type-" + product.auth_type.replace(REGEX_NON_WORDS,"-");
product.filter_classes += " filter-deployment-model-" + product.deployment_model.replace(REGEX_NON_WORDS,"-");
product.filter_classes += " filter-small-business-" + product.small_business.replace(REGEX_NON_WORDS,"-");
product.filter_classes += " filter-assessor-" + product.independent_assessor.replace(REGEX_NON_WORDS,"-");
for(var j = 0; j < product.service_model.length; j++) {
product.filter_classes += " filter-service-model-" + product.service_model[j].replace(REGEX_NON_WORDS,"-");
}
for(var j = 0; j < product.business_function.length; j++) {
product.filter_classes += " filter-business-function-" + product.business_function[j].replace(REGEX_NON_WORDS,"-");
}
json.data.Products.push(product); // Build array of Products
}
json.data.Products = quickSortOnObjectCSP(json.data.Products, 0, json.data.Products.length-1); // Sort
/**
* This object should ALWAYS contain more than 3 items before the splice(). If this
* line blows up, there are bigger problems.
*/
json.data.Metrics.latest = quickSortOnObjectDate(json.data.Metrics.latest, 0, json.data.Metrics.latest.length-1).splice(0,3);
/***************************************************************************************************/
/**
* Agencies
*/
var agency = {
filter_classes: String,
id: String,
parent: String,
sub_id: String,
sub: String,
csp: String,
logo: String,
authorization: Number,
reuse: Number,
email: String,
website: String,
auths: [],
reuses: [],
procs: []
}
l(" Agencies");
initErrorCols(MASTER_AGENCY_TAB_SHEET);
var masterAgencyVals = ss.getSheetByName(MASTER_AGENCY_TAB_SHEET).getDataRange().getValues();
/**
* Loop through values on this tab, filling fields. Special processing generally happens at the bottom of the loop.
*/
for(var i = 1; i < masterAgencyVals.length; i++) {
if(masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS,"Agency ID")] == ""
|| masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS,"Agency Name")] == ""
|| masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS,"Authorizations Number")] == "") {
continue;
}
agency = {};
agency.id = masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS,"Agency ID")];
agency.parent = masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS, "Agency Name")];
agency.sub = masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS, "Sub Agency")];
if(agency.parent == agency.sub) { // Sub and Parent the same?
agency.sub = ""; // Remove. We don't want it displayed twice on the webpage.
}
if(agency.sub != "") {
agency.sub_id = agency.id;
}
agency.csp = concatParentSub(agency.parent, agency.sub);
agency.logo = masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS, "Logo URL")];
agency.authorization = masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS, "Authorizations Number")];
agency.reuse = masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS, "Reuse Number")];
agency.email = masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS, "E-mail")];
agency.website = masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS, "Website")];
// Build and sort before storing
workArr = getItems(masterAuthVals, Array.from(new Set(masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS, "Authorizations")].split("|"))));
agency.auths = quickSortOnObjectCSP(workArr, 0, workArr.length-1);
// Build and sort before storing
workArr = getItems(masterAuthVals, Array.from(new Set(masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS, "Reuse")].split("|"))));
agency.reuses = quickSortOnObjectCSP(workArr, 0, workArr.length-1);
// Build and sort before storing. There's a concat snuck in here, too.
workArr = getItems(masterAuthVals, Array.from(new Set(masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS, "In Process (Agency Review)")].split("|"))), "Agency Review").concat(getItems(masterAuthVals, Array.from(new Set(masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS, "In Process (FedRAMP Review)")].split("|"))),"FedRAMP Review"), getItems(masterAuthVals, Array.from(new Set(masterAgencyVals[i][getCol(MASTER_AGENCY_TAB_HEADERS, "In Process (JAB Review)")].split("|"))),"JAB Review"));
agency.procs = quickSortOnObjectCSP(workArr, 0, workArr.length-1);
// Filter classes
agency.filter_classes = "";
agency.filter_classes += " filter-parent-agency-" + agency.parent.replace(REGEX_NON_WORDS,"-");
agency.filter_classes += getFilterClassBucket("authorization", agency.authorization);
agency.filter_classes += getFilterClassBucket("reuse", agency.reuse);
agency.filter_classes += getFilterClassImpactAndOffering(Array.from(new Set(agency.auths.concat(agency.procs))));
json.data.Agencies.push(agency); // Build array of Agencies
}
json.data.Agencies = quickSortOnObjectCSP(json.data.Agencies, 0, json.data.Agencies.length-1);
/***************************************************************************************************/
/**
* Assessors
*/
var assessor = {
filter_classes: String,
id: String,
name: String,
csp: String,
logo: String,
products_assessing: Number,
accredited_since: String,
poc: String,
email: String,
founded: String,
address: String,
desc: String,
services: String,
csps: String,
frameworks: String,
clients: []
}
l(" Assessors");
initErrorCols(MASTER_3PAO_LIST_SHEET);
var master3paoVals = ss.getSheetByName(MASTER_3PAO_LIST_SHEET).getDataRange().getValues();
/**
* Loop through values on this tab, filling fields. Special processing generally happens at the bottom of the loop.
*/
for(var i = 1; i < master3paoVals.length; i++) {
if(master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "3PAO ID#")] == "") {
continue;
}
assessor = {};
assessor.id = master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "3PAO ID#")];
assessor.name = master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "3PAO Name")];
assessor.csp = assessor.name;
assessor.logo = master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "Logo URL")];
assessor.products_assessing = master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "Products Assessing (Number)")];
assessor.accredited_since = master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "FedRAMP Accreditation Date")];
assessor.poc = master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "POC Name")];
assessor.email = master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "POC Email")];
assessor.founded = master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "Year Company Founded")];
assessor.address = master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "Primary Office Locations")];
assessor.desc = master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "Description of 3PAO Services")];
if(master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "Consulting Services?")] == 'Y') {
assessor.services = master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "Description of Consulting Services")];
}
assessor.csps = master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "CSPs providing consulting service to")];
assessor.frameworks = master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "Additional Cyber Frameworks Your Company Is Accredited to Perform")];
// Build and sort before storing
workArr = getItems(masterAuthVals, Array.from(new Set(master3paoVals[i][getCol(MASTER_3PAO_LIST_HEADERS, "Current Clients")].split("|"))));
assessor.clients = quickSortOnObjectCSP(workArr, 0, workArr.length-1);
// Filter classes
assessor.filter_classes = "";
assessor.filter_classes += getFilterClassBucket("products-assessing", assessor.products_assessing);
assessor.filter_classes += getFilterClassImpactAndOffering(assessor.clients);
json.data.Assessors.push(assessor); // Build array of Assessors
}
json.data.Assessors = quickSortOnObjectCSP(json.data.Assessors, 0, json.data.Assessors.length-1);
/***************************************************************************************************/
/**
* Product Filters
*/
l(" Product Filters");
var filter = {
name: String,
class_name: String
}
var productFilters = {
status: [],
business_function: [],
service_model: [],
impact_level: [],
auth_type: [],
deployment_models: [],
small_business: [],
assessor: []
}
productFilters.status = getFilter("status", masterAuthVals, MASTER_AUTHORIZATION_STATUS_HEADERS, "Current Active Status?");
productFilters.business_function = getFilter("business-function", masterAuthVals, MASTER_AUTHORIZATION_STATUS_HEADERS, "CSP Business Function");
productFilters.service_model = getFilter("service-model", masterAuthVals, MASTER_AUTHORIZATION_STATUS_HEADERS, "Service Model");
productFilters.impact_level.push({ name: "LI-SaaS", class_name: "filter-impact-level-LI-SaaS"});
productFilters.impact_level.push({ name: "Low", class_name: "filter-impact-level-Low"});
productFilters.impact_level.push({ name: "Moderate",class_name: "filter-impact-level-Moderate"});
productFilters.impact_level.push({ name: "High", class_name: "filter-impact-level-High"});
productFilters.auth_type = getFilter("auth-type", masterAuthVals, MASTER_AUTHORIZATION_STATUS_HEADERS, "Authorization Path");
productFilters.auth_type.splice(productFilters.auth_type.indexOf("Program"),1);
productFilters.deployment_models = getFilter("deployment-model", masterAuthVals, MASTER_AUTHORIZATION_STATUS_HEADERS, "Deployment Model");
// productFilters.small_business.push({ name: "Yes", class_name: "filter-small-business-Yes"});
// productFilters.small_business.push({ name: "No", class_name: "filter-small-business-No"});
productFilters.assessor = getFilter("assessor", masterAuthVals, MASTER_AUTHORIZATION_STATUS_HEADERS, "Current 3PAO ID");
json.data.Filters.product = productFilters;
/***************************************************************************************************/
/**
* Agency Filters
*/
l(" Agency Filters");
var agencyFilters = {
parent_agency: [],
authorization: [],
reuse: [],
impact_level: []
}
agencyFilters.parent_agency = getFilter("parent-agency", masterAgencyVals, MASTER_AGENCY_TAB_HEADERS, "Agency Name");
// if these numbers change, also change logic in getFilterClassBucket
agencyFilters.authorization.push({ name: "0-5", class_name: "filter-authorization-1"});
agencyFilters.authorization.push({ name: "6-10", class_name: "filter-authorization-2"});
agencyFilters.authorization.push({ name: "11-20", class_name: "filter-authorization-3"});
agencyFilters.authorization.push({ name: "21+", class_name: "filter-authorization-4"});
agencyFilters.reuse.push({ name: "0-5", class_name: "filter-reuse-1"});
agencyFilters.reuse.push({ name: "6-10", class_name: "filter-reuse-2"});
agencyFilters.reuse.push({ name: "11-20", class_name: "filter-reuse-3"});
agencyFilters.reuse.push({ name: "21+", class_name: "filter-reuse-4"});
agencyFilters.impact_level.push({ name: "LI-SaaS", class_name: "filter-impact-level-LI-SaaS"});
agencyFilters.impact_level.push({ name: "Low", class_name: "filter-impact-level-Low"});
agencyFilters.impact_level.push({ name: "Moderate",class_name: "filter-impact-level-Moderate"});
agencyFilters.impact_level.push({ name: "High", class_name: "filter-impact-level-High"});
json.data.Filters.agency = agencyFilters;
/***************************************************************************************************/
/**
* Assessor Filters
*/
l(" Assessor Filters");
var assessorFilters = {
product_assessing: [],
impact_level: [],
status: []
}
assessorFilters.product_assessing.push({ name: "0-5", class_name: "filter-products-assessing-1"});
assessorFilters.product_assessing.push({ name: "6-10", class_name: "filter-products-assessing-2"});
assessorFilters.product_assessing.push({ name: "11-20", class_name: "filter-products-assessing-3"});
assessorFilters.product_assessing.push({ name: "21+", class_name: "filter-products-assessing-4"});
assessorFilters.impact_level = json.data.Filters.product.impact_level;
assessorFilters.status = json.data.Filters.product.status;
json.data.Filters.assessor = assessorFilters;
/***************************************************************************************************/
/**
* AtoMapping
*/
var atoRec = {
id: "",
agency_id: "",
parent: "",
sub: "",
ato_date: "",
auth_date: "",
exp_date: "",
assessment_date: ""
}
l(" Initial ATOs");
initErrorCols(INITIAL_ATOS_SHEET);
var initialAtoVals = ss.getSheetByName(INITIAL_ATOS_SHEET).getDataRange().getValues();
for(var i = 1; i < initialAtoVals.length; i++) {
if(initialAtoVals[i][getCol(INITIAL_ATOS_HEADERS, "Active?")] != "Y") {
continue;
}
atoRec = {};
atoRec.id = initialAtoVals[i][getCol(INITIAL_ATOS_HEADERS, "FR ID#")];
atoRec.agency_id = initialAtoVals[i][getCol(INITIAL_ATOS_HEADERS, "Actual Authorizing Agency (keep hidden)")];
atoRec.parent = initialAtoVals[i][getCol(INITIAL_ATOS_HEADERS, "Agency Name (Keep Hidden)")];
atoRec.sub = initialAtoVals[i][getCol(INITIAL_ATOS_HEADERS, "Sub Agency Name (Keep hidden)")];
atoRec.ato_date = initialAtoVals[i][getCol(INITIAL_ATOS_HEADERS, "Agency ATO Date")];
atoRec.auth_date = initialAtoVals[i][getCol(INITIAL_ATOS_HEADERS, "Authorization Date")];
atoRec.exp_date = initialAtoVals[i][getCol(INITIAL_ATOS_HEADERS, "ATO Expiration")];
atoRec.assessment_date = initialAtoVals[i][getCol(INITIAL_ATOS_HEADERS, "Annual Assessment Date")];
json.data.AtoMapping.push(atoRec); // Build array of Assessors
}
json.data.AtoMapping = quickSortOnObjectId(json.data.AtoMapping, 0, json.data.AtoMapping.length-1);
/***************************************************************************************************/
/**
* reuseMapping
*/
var reuseRec = {
id: "",
agency_id: "",
parent: "",
sub_id: "",
sub: "",
ato_date: "",
auth_date: "",
exp_date: ""
}
l(" Reuse ATOs");
initErrorCols(REUSE_ATOS_SHEET);
var reuseVals = ss.getSheetByName(REUSE_ATOS_SHEET).getDataRange().getValues();
for(var i = 1; i < reuseVals.length; i++) {
if(reuseVals[i][getCol(REUSE_ATOS_HEADERS, "Active?")] != "Y") {
continue;
}
reuseRec = {};
reuseRec.id = reuseVals[i][getCol(REUSE_ATOS_HEADERS, "FR ID")];
reuseRec.agency_id = reuseVals[i][getCol(REUSE_ATOS_HEADERS, "Agency ID #")];
reuseRec.parent = reuseVals[i][getCol(REUSE_ATOS_HEADERS, "Agency (Keep Hidden)")];
reuseRec.sub_id = reuseVals[i][getCol(REUSE_ATOS_HEADERS, "Sub Agency #")];
reuseRec.sub = reuseVals[i][getCol(REUSE_ATOS_HEADERS, "Sub Agency Name (Keep hidden)")];
reuseRec.ato_date = reuseVals[i][getCol(REUSE_ATOS_HEADERS, "Agency Authorization")];
reuseRec.auth_date = reuseVals[i][getCol(REUSE_ATOS_HEADERS, "Authorization Logged Date")];
reuseRec.exp_date = reuseVals[i][getCol(REUSE_ATOS_HEADERS, "ATO Expiration")];
json.data.ReuseMapping.push(reuseRec); // Build array of Assessors
}
json.data.ReuseMapping = quickSortOnObjectId(json.data.ReuseMapping, 0, json.data.ReuseMapping.length-1);
/***************************************************************************************************/
return JSON.stringify(json, null);
}
/***************************************************************************************************/
/**
* Find the latest date from the last 5 fields passed in (if any of them have dates).
*
* @param {frr} - Possible date (FedRAMP Ready)
* @param {jab} - Possible date (JAB Review)
* @param {agency} - Possible date (Agency Review)
* @param {pmo} - Possible date (PMO Review)
* @param {auth} - Possible date (Auth Review)
* @returns {Object} - Latest date and its "status" (description of date)
*/
function getLatest(id, logo, cso, frr, jab, prog, agency, pmo, auth) {
var rec = {
id: String,
logo: String,
cso: String,
date: String,
status: String
}
// No good dates? Return.
if(frr == NO_FRR && jab == NO_JAB && prog == NO_PROG && agency == NO_AGENCY && pmo == NO_PMO && auth == NO_AUTH) {
return rec;
}
rec.id = id;
rec.logo = logo;
rec.cso = cso;
// Find latest date
var item = maxDate(maxDate(maxDate(maxDate(maxDate(
{date: scrubNo(frr), status: STATUS_FRR},
{date: scrubNo(jab), status: STATUS_JAB}),
{date: scrubNo(prog), status: STATUS_PROG}),
{date: scrubNo(agency), status: STATUS_AGENCY}),
{date: scrubNo(pmo), status: STATUS_PMO}),
{date: scrubNo(auth), status: STATUS_AUTH});
rec.date = item.date;
rec.status = item.status;
return rec;
}
/***************************************************************************************************/
/**
* This utility function is used to clear any default literals within a date field.
*
* @param {inDate} - Possible detault literal or actual date.
* @returns {String} - Empty or the date passed in.
*/
function scrubNo(inDate) {
if(inDate == NO_FRR || inDate == NO_JAB || inDate == NO_PROG || inDate == NO_AGENCY || inDate == NO_PMO || inDate == NO_AUTH) {
return "";
}
return inDate;
}
/***************************************************************************************************/
/**
* Returns the greater date between two Objects containing a .date variable.
*
* @param {a} - Object of Date and Status (date description)
* @param {b} - Object of Date and Status (date description)
* @returns {Object} - Date and Status of "latest" date
*/
function maxDate(a, b) {
if(a.date > b.date) {
return a;
}
return b;
}
/***************************************************************************************************/
/**
* Get unique sorted list of all values present in a column.
*
* @param {inLabel} - Label to be applied to the filter so each category is unique.
* @param {inVals} - Values from a sheet
* @param {inHeaders} - Array of headers from a sheet
* @param {inCol} - Column
* @returns {Object} -
*/
function getFilter(inLabel, inVals, inHeaders, inCol) {
var filter = {
name: String,
class_name: String
}
var filterArr = [];
for(var i = 1; i < inVals.length; i++) {
filterArr = filterArr.concat(inVals[i][getCol(inHeaders, inCol)].split("|")); // Some columns are pipe-delimited
}
// The easiest way to dedup an array is to force it into a Set
filterArr = Array.from(new Set(filterArr)).sort();
var filters = [];
for(var i = 0; i < filterArr.length; i++) {
filter = {};
filter.name = filterArr[i];
filter.class_name = "filter-" + inLabel + "-" + filterArr[i].replace(REGEX_NON_WORDS, "-");
if (filter.name != "" && filterArr[i] != "No Status Found") {
filters.push(filter);
}
}
return filters;
}
/***************************************************************************************************/
/**
* This function initializes the error sheet name and array to
* the sheet name about to be processed. The array will ultimately hold
* unique sheet/col info so we don't get hundreds of identical messages
* about columns missing.
*
* @param {inSheet} - active spreadsheet being processed
*/
function initErrorCols(inSheet) {
errSheet = inSheet;
errArr = [];
}
/***************************************************************************************************/
/**
* Prints a unique error message and adds it to an array so
* it won't be duplicated. This uses the global sheet name
* set in initErrorCols() above.
*
* @param {inCol} - column not found
*/
function addErrorCol(inCol) {
var errMsg = "Sheet<" + errSheet + "> Col<" + inCol + ">";
if(errArr.indexOf(errMsg) == -1) { // Unique message?
l(errMsg); // Print it
errArr.push(errMsg); // Add it to the error array so a future duplicate won't be printed.
}
}
/***************************************************************************************************/
/**
* Attempt to find a column within an array of header names.
*
* @param {inHeaders} - Array of header names
* @param {inCol} - index of column to find
* @returns {Integer} - index of column found in array of headers. -1 if not found.
*/
function getCol(inHeaders, inCol) {
var colNum = inHeaders.indexOf(inCol); // Find index of column in header array
if(colNum == -1) { // Not found?
addErrorCol(inCol); // Print unique missing columns
}
return colNum; // Return index
}
/***************************************************************************************************/
/**
* In several locations of the AuthLog cells contain a pipe-delimited list of
* IDs that are used to create an array of objects containing info from
* corresponding entries on the Master Authorization Status sheet.
*
* @param {masterAuthVals} - 2D array of values from the Master Authorization Status sheet so they don't have to be retrieved multiple times.
* @param {itemArray} - Array of Master Authorization Status IDs
* @returns {Array of Objects} - Array of "item" objects
*/
function getItems(masterAuthVals, itemArray, inConst = "") {
var item = {
id: String,
csp: String,
cso: String,
status: String,
impact: String
}
var list = [];
/**
* Loop through each ID from the array
*/
for(var j = 0; j < itemArray.length; j++) {
/**
* The itemArray is created from a string being split(). The result will
* be at least 1 item (even if it's splitting a null field). Check for blank before
* looping through everything.
*/
if(itemArray[j] != "") {
/**
* Loop through the Master Authorization Status rows, looking for the ID.
*/
for(var k = 1; k < masterAuthVals.length; k++) {
/**
* If ID matches, push an item onto the array
*/
if(itemArray[j] == masterAuthVals[k][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "FR ID#")] &&
masterAuthVals[k][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Current Active Status?")] != "No Status Found") {
item = {}
item.id = masterAuthVals[k][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "FR ID#")];
item.csp = masterAuthVals[k][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "CSP")];
item.cso = masterAuthVals[k][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "CSO")];
if(inConst != "") {
item.status = inConst;
} else {
item.status = masterAuthVals[k][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Current Active Status?")];
}
item.impact_level = masterAuthVals[k][getCol(MASTER_AUTHORIZATION_STATUS_HEADERS, "Impact Level")];
item.impact_level_number = getImpactLevelNumber(item.impact_level);
list.push(item);
break;
}
}
}
}
return list;
}
/***************************************************************************************************/
/**
* Individually validates each sheet and their columns
*