1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var plugin = {
|
18 | ruleId: "EX-PO007",
|
19 | name: "Policy Naming Conventions - type indication",
|
20 | message:
|
21 | "It is recommended that the policy name include an indicator of the policy type.",
|
22 | fatal: false,
|
23 | severity: 1,
|
24 | nodeType: "Policy",
|
25 | enabled: true
|
26 | },
|
27 | policyMetaData = {
|
28 | AccessControl: { indications: ["AC-"] },
|
29 | AccessEntity: { indications: ["AE-"] },
|
30 | AssignMessage: { indications: ["AM-"] },
|
31 | BasicAuthentication: {indications: ["BA-"] },
|
32 | ExtractVariables: { indications: ["EV-"] },
|
33 | FlowCallout: { indications: ["FC-"] },
|
34 | GenerateSAMLAssertion: { indications: ["SA-"] },
|
35 | GetOAuthV1Info:{indications: ["OA-"]},
|
36 | GetOAuthV2Info: {indications: ["OA-"]},
|
37 | InvalidateCache: {indications: ["CI-"] },
|
38 | JSONThreatProtection: {indications: ["JT-"] },
|
39 | JSONToXML: { indications: ["JX-"] },
|
40 | JavaCallout: { indications: ["JC-"] },
|
41 | Javascript: { indications: ["JS-"] },
|
42 | KeyValueMapOperations: {indications: ["KV-"] },
|
43 | Ldap: { indications: ["LD-"] },
|
44 | LookupCache: { indications: ["CL-"] },
|
45 | MessageLogging: { indications: ["ML-"] },
|
46 | MessageValidation: { indications: ["MV-"] },
|
47 | OAuthV1: {indications: ["OA-"]},
|
48 | OAuthV2: {indications: ["OA-"]},
|
49 | PopulateCache: {indications: ["CP-"] },
|
50 | Quota: { indications: ["QU-"] },
|
51 | RaiseFault: { indications: ["RF-"] },
|
52 | RegularExpressionProtection: { indications: ["RE-"] },
|
53 | ResetQuota: { indications: ["QR-"] },
|
54 | ResponseCache: { indications: ["RC-"] },
|
55 | Script: { indications: ["PY-"] },
|
56 | ServiceCallout: { indications: ["SC-"] },
|
57 | SpikeArrest: { indications: ["SA-"] },
|
58 | StatisticsCollector: { indications: ["SC-"] },
|
59 | VerifyAPIKey: { indications: ["VK-"] },
|
60 | XMLThreatProtection: { indications: ["XT-"] },
|
61 | XMLToJSON: { indications: ["XJ-"] },
|
62 | XSL: { indications: ["XS-"] },
|
63 | "": { indications: [] }
|
64 | };
|
65 |
|
66 | var onPolicy = function(policy, cb) {
|
67 | var displayName = policy.getDisplayName(),
|
68 | policyType = policy.getType(),
|
69 | prefixes = policyMetaData[policyType].indications,
|
70 | found = false,
|
71 | hadWarn = false;
|
72 |
|
73 | prefixes.some(function(prefix) {
|
74 | if (displayName.startsWith(prefix)) {
|
75 | found = true;
|
76 | return;
|
77 | }
|
78 | });
|
79 |
|
80 | if (!found || displayName === "") {
|
81 | policy.addMessage({
|
82 | plugin,
|
83 | message:
|
84 | 'Naming Conventions: Policy "' +
|
85 | displayName +
|
86 | '" of type "' +
|
87 | policyType +
|
88 | '" should have an indicative prefix. Valid prefixes include: ' +
|
89 | JSON.stringify(prefixes)
|
90 | });
|
91 | hadWarn = true;
|
92 | }
|
93 | if (typeof cb == "function") {
|
94 | cb(null, hadWarn);
|
95 | }
|
96 | };
|
97 |
|
98 | module.exports = {
|
99 | plugin,
|
100 | onPolicy
|
101 | };
|