@routr/common 2.17.0 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connect/config.d.ts +5 -1
- package/dist/connect/mappers/agent.js +1 -0
- package/dist/connect/mappers/domain.js +1 -0
- package/dist/connect/mappers/peer.js +1 -0
- package/dist/connect/mappers/trunk.js +1 -0
- package/dist/connect/protos/agents.proto +7 -0
- package/dist/connect/protos/domains.proto +7 -0
- package/dist/connect/protos/peers.proto +7 -0
- package/dist/connect/protos/trace.proto +28 -0
- package/dist/connect/protos/trunks.proto +7 -0
- package/dist/connect/schemas/agent.d.ts +10 -0
- package/dist/connect/schemas/agent.js +8 -0
- package/dist/connect/schemas/domain.d.ts +10 -0
- package/dist/connect/schemas/domain.js +8 -0
- package/dist/connect/schemas/peer.d.ts +10 -0
- package/dist/connect/schemas/peer.js +8 -0
- package/dist/connect/schemas/trunk.d.ts +10 -0
- package/dist/connect/schemas/trunk.js +8 -0
- package/dist/connect/types.d.ts +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/protos/processor.proto +4 -0
- package/dist/trace/compat.d.ts +37 -0
- package/dist/trace/compat.js +131 -0
- package/dist/trace/diff.d.ts +48 -0
- package/dist/trace/diff.js +152 -0
- package/dist/trace/index.d.ts +11 -0
- package/dist/trace/index.js +68 -0
- package/dist/trace/metadata.d.ts +28 -0
- package/dist/trace/metadata.js +75 -0
- package/dist/trace/normalize.d.ts +11 -0
- package/dist/trace/normalize.js +39 -0
- package/dist/trace/redact.d.ts +19 -0
- package/dist/trace/redact.js +52 -0
- package/dist/trace/rules/facts.d.ts +43 -0
- package/dist/trace/rules/facts.js +117 -0
- package/dist/trace/rules/index.d.ts +34 -0
- package/dist/trace/rules/index.js +153 -0
- package/dist/trace/rules/sip/ack-2xx.d.ts +2 -0
- package/dist/trace/rules/sip/ack-2xx.js +56 -0
- package/dist/trace/rules/sip/cancel-matches.d.ts +2 -0
- package/dist/trace/rules/sip/cancel-matches.js +46 -0
- package/dist/trace/rules/sip/credentials-stripped.d.ts +2 -0
- package/dist/trace/rules/sip/credentials-stripped.js +41 -0
- package/dist/trace/rules/sip/cseq-ack.d.ts +2 -0
- package/dist/trace/rules/sip/cseq-ack.js +40 -0
- package/dist/trace/rules/sip/cseq-monotonic.d.ts +2 -0
- package/dist/trace/rules/sip/cseq-monotonic.js +50 -0
- package/dist/trace/rules/sip/max-forwards.d.ts +2 -0
- package/dist/trace/rules/sip/max-forwards.js +47 -0
- package/dist/trace/rules/sip/private-address.d.ts +2 -0
- package/dist/trace/rules/sip/private-address.js +48 -0
- package/dist/trace/rules/sip/record-route-self.d.ts +2 -0
- package/dist/trace/rules/sip/record-route-self.js +46 -0
- package/dist/trace/rules/sip/register-ok.d.ts +2 -0
- package/dist/trace/rules/sip/register-ok.js +52 -0
- package/dist/trace/rules/sip/retransmission.d.ts +2 -0
- package/dist/trace/rules/sip/retransmission.js +47 -0
- package/dist/trace/rules/sip/route-self-removed.d.ts +2 -0
- package/dist/trace/rules/sip/route-self-removed.js +38 -0
- package/dist/trace/rules/sip/via.d.ts +2 -0
- package/dist/trace/rules/sip/via.js +50 -0
- package/dist/trace/rules/sip-connect/from-e164-or-anonymous.d.ts +2 -0
- package/dist/trace/rules/sip-connect/from-e164-or-anonymous.js +43 -0
- package/dist/trace/rules/sip-connect/pai-e164.d.ts +2 -0
- package/dist/trace/rules/sip-connect/pai-e164.js +44 -0
- package/dist/trace/rules/sip-connect/pai-single.d.ts +2 -0
- package/dist/trace/rules/sip-connect/pai-single.js +41 -0
- package/dist/trace/rules/sip-connect/privacy.d.ts +2 -0
- package/dist/trace/rules/sip-connect/privacy.js +50 -0
- package/dist/trace/rules/sip-connect/request-uri-e164.d.ts +2 -0
- package/dist/trace/rules/sip-connect/request-uri-e164.js +44 -0
- package/dist/trace/rules/sip-connect/scope.d.ts +11 -0
- package/dist/trace/rules/sip-connect/scope.js +19 -0
- package/dist/trace/rules/types.d.ts +34 -0
- package/dist/trace/rules/types.js +13 -0
- package/dist/trace/sanitize.d.ts +40 -0
- package/dist/trace/sanitize.js +85 -0
- package/dist/trace/schema.d.ts +338 -0
- package/dist/trace/schema.js +197 -0
- package/dist/trace/status.d.ts +15 -0
- package/dist/trace/status.js +102 -0
- package/dist/trace/types.d.ts +126 -0
- package/dist/trace/types.js +82 -0
- package/dist/trace/validate.d.ts +56 -0
- package/dist/trace/validate.js +140 -0
- package/dist/types.d.ts +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster/routr
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Routr.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License");
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
const types_1 = require("../types");
|
|
22
|
+
const types_2 = require("../../types");
|
|
23
|
+
const facts_1 = require("../facts");
|
|
24
|
+
exports.default = (0, types_1.defineRule)({
|
|
25
|
+
id: "sip/retransmission",
|
|
26
|
+
profile: types_2.Profile.SIP,
|
|
27
|
+
severity: types_2.Severity.WARNING,
|
|
28
|
+
spec: "RFC 3261 §17.1.1.2, §17.1.2.2",
|
|
29
|
+
summary: "A request seen twice with the same branch means its response did not reach the sender in time"
|
|
30
|
+
}, ({ record, call }, fail) => {
|
|
31
|
+
var _a;
|
|
32
|
+
if (!(0, facts_1.isRequest)(record))
|
|
33
|
+
return;
|
|
34
|
+
const branch = (0, facts_1.topBranch)((0, facts_1.inbound)(record));
|
|
35
|
+
const cseq = (_a = (0, facts_1.cseqOf)((0, facts_1.inbound)(record))) === null || _a === void 0 ? void 0 : _a.number;
|
|
36
|
+
if (!branch || cseq === undefined)
|
|
37
|
+
return;
|
|
38
|
+
const earlier = (0, facts_1.requestsIn)(call).find((r) => {
|
|
39
|
+
var _a;
|
|
40
|
+
return r.method === record.method &&
|
|
41
|
+
(0, facts_1.topBranch)((0, facts_1.inbound)(r)) === branch &&
|
|
42
|
+
((_a = (0, facts_1.cseqOf)((0, facts_1.inbound)(r))) === null || _a === void 0 ? void 0 : _a.number) === cseq;
|
|
43
|
+
});
|
|
44
|
+
if (earlier) {
|
|
45
|
+
return fail(`${record.method} retransmitted ${Math.round(record.tOffsetMs - earlier.tOffsetMs)} ms after the first copy (seq ${earlier.seq}): the sender had not seen a response`, "in", "Via");
|
|
46
|
+
}
|
|
47
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster/routr
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Routr.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License");
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
const types_1 = require("../types");
|
|
22
|
+
const types_2 = require("../../types");
|
|
23
|
+
const facts_1 = require("../facts");
|
|
24
|
+
exports.default = (0, types_1.defineRule)({
|
|
25
|
+
id: "sip/route-self-removed",
|
|
26
|
+
profile: types_2.Profile.SIP,
|
|
27
|
+
severity: types_2.Severity.ERROR,
|
|
28
|
+
spec: "RFC 3261 §16.4",
|
|
29
|
+
summary: "A Route pointing at the proxy itself is removed before forwarding"
|
|
30
|
+
}, ({ record }, fail) => {
|
|
31
|
+
var _a;
|
|
32
|
+
if (!(0, facts_1.isForwarded)(record))
|
|
33
|
+
return;
|
|
34
|
+
const own = (((_a = (0, facts_1.outbound)(record)) === null || _a === void 0 ? void 0 : _a.route) || []).find((r) => { var _a, _b; return (0, facts_1.isOwnHost)(record.request, (_b = (_a = r.address) === null || _a === void 0 ? void 0 : _a.uri) === null || _b === void 0 ? void 0 : _b.host); });
|
|
35
|
+
if (own) {
|
|
36
|
+
return fail(`outgoing request still carries a Route to ${own.address.uri.host}, one of the proxy's interfaces`, "out", "Route");
|
|
37
|
+
}
|
|
38
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster/routr
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Routr.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License");
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
const types_1 = require("../types");
|
|
22
|
+
const types_2 = require("../../types");
|
|
23
|
+
const facts_1 = require("../facts");
|
|
24
|
+
exports.default = (0, types_1.defineRule)({
|
|
25
|
+
id: "sip/via",
|
|
26
|
+
profile: types_2.Profile.SIP,
|
|
27
|
+
severity: types_2.Severity.ERROR,
|
|
28
|
+
spec: "RFC 3261 §16.6 step 8, §16.7 step 3",
|
|
29
|
+
summary: "The proxy's own Via goes on top of a forwarded request and comes off a relayed response"
|
|
30
|
+
}, ({ record }, fail) => {
|
|
31
|
+
var _a, _b, _c, _d, _e;
|
|
32
|
+
const viaIn = (0, facts_1.inbound)(record).via || [];
|
|
33
|
+
const viaOut = ((_a = (0, facts_1.outbound)(record)) === null || _a === void 0 ? void 0 : _a.via) || [];
|
|
34
|
+
if ((0, facts_1.isForwarded)(record)) {
|
|
35
|
+
if (viaOut.length !== viaIn.length + 1) {
|
|
36
|
+
return fail(`expected ${viaIn.length + 1} Via headers on the outgoing request, found ${viaOut.length}`, "out", "Via");
|
|
37
|
+
}
|
|
38
|
+
if (!(0, facts_1.isOwnHost)(record.request, (_b = viaOut[0]) === null || _b === void 0 ? void 0 : _b.host)) {
|
|
39
|
+
return fail(`top Via of the outgoing request is ${(_c = viaOut[0]) === null || _c === void 0 ? void 0 : _c.host}, not one of the proxy's interfaces`, "out", "Via");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if ((0, facts_1.isRelayed)(record)) {
|
|
43
|
+
if (viaOut.length !== viaIn.length - 1) {
|
|
44
|
+
return fail(`expected ${viaIn.length - 1} Via headers on the relayed response, found ${viaOut.length}`, "out", "Via");
|
|
45
|
+
}
|
|
46
|
+
if (viaIn.length && !(0, facts_1.isOwnHost)(record.request, (_d = viaIn[0]) === null || _d === void 0 ? void 0 : _d.host)) {
|
|
47
|
+
return fail(`top Via of the incoming response is ${(_e = viaIn[0]) === null || _e === void 0 ? void 0 : _e.host}, not one of the proxy's interfaces`, "in", "Via");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster/routr
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Routr.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License");
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
const types_1 = require("../types");
|
|
22
|
+
const types_2 = require("../../types");
|
|
23
|
+
const facts_1 = require("../facts");
|
|
24
|
+
const scope_1 = require("./scope");
|
|
25
|
+
exports.default = (0, types_1.defineRule)({
|
|
26
|
+
id: "sip-connect/from-e164-or-anonymous",
|
|
27
|
+
profile: types_2.Profile.SIP_CONNECT,
|
|
28
|
+
severity: types_2.Severity.WARNING,
|
|
29
|
+
spec: "SIPconnect 1.1, calling party identity and privacy (tests 1.3.1, 1.3.4)",
|
|
30
|
+
summary: "From carries an E.164 number or the anonymous identity"
|
|
31
|
+
}, ({ record }, fail) => {
|
|
32
|
+
var _a, _b, _c, _d, _e, _f;
|
|
33
|
+
if (!(0, scope_1.towardServiceProvider)(record))
|
|
34
|
+
return;
|
|
35
|
+
const from = (_c = (_b = (_a = (0, facts_1.outbound)(record)) === null || _a === void 0 ? void 0 : _a.from) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c.uri;
|
|
36
|
+
if (!from)
|
|
37
|
+
return;
|
|
38
|
+
const anonymous = ((_d = from.user) === null || _d === void 0 ? void 0 : _d.toLowerCase()) === "anonymous" ||
|
|
39
|
+
((_e = from.host) === null || _e === void 0 ? void 0 : _e.toLowerCase()) === "anonymous.invalid";
|
|
40
|
+
if (!anonymous && !(0, facts_1.isE164)(from.user)) {
|
|
41
|
+
return fail(`From user ${(_f = from.user) !== null && _f !== void 0 ? _f : ""} is neither E.164 nor anonymous`, "out", "From");
|
|
42
|
+
}
|
|
43
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster/routr
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Routr.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License");
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
const types_1 = require("../types");
|
|
22
|
+
const types_2 = require("../../types");
|
|
23
|
+
const facts_1 = require("../facts");
|
|
24
|
+
const scope_1 = require("./scope");
|
|
25
|
+
exports.default = (0, types_1.defineRule)({
|
|
26
|
+
id: "sip-connect/pai-e164",
|
|
27
|
+
profile: types_2.Profile.SIP_CONNECT,
|
|
28
|
+
severity: types_2.Severity.ERROR,
|
|
29
|
+
spec: "SIPconnect 1.1, calling party identity, E.164 with user=phone (test 1.3.1)",
|
|
30
|
+
summary: "P-Asserted-Identity is a global E.164 number with user=phone"
|
|
31
|
+
}, ({ record }, fail) => {
|
|
32
|
+
if (!(0, scope_1.towardServiceProvider)(record))
|
|
33
|
+
return;
|
|
34
|
+
const pai = (0, facts_1.headerValues)((0, facts_1.outbound)(record), "P-Asserted-Identity")[0];
|
|
35
|
+
if (!pai)
|
|
36
|
+
return;
|
|
37
|
+
const uri = (0, facts_1.uriOf)(pai);
|
|
38
|
+
if (!uri || !(0, facts_1.isE164)(uri.user)) {
|
|
39
|
+
return fail(`P-Asserted-Identity is not E.164: ${pai}`, "out", "P-Asserted-Identity");
|
|
40
|
+
}
|
|
41
|
+
if (!/user=phone/.test(uri.params)) {
|
|
42
|
+
return fail(`P-Asserted-Identity lacks user=phone: ${pai}`, "out", "P-Asserted-Identity");
|
|
43
|
+
}
|
|
44
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster/routr
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Routr.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License");
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
const types_1 = require("../types");
|
|
22
|
+
const types_2 = require("../../types");
|
|
23
|
+
const facts_1 = require("../facts");
|
|
24
|
+
const scope_1 = require("./scope");
|
|
25
|
+
exports.default = (0, types_1.defineRule)({
|
|
26
|
+
id: "sip-connect/pai-single",
|
|
27
|
+
profile: types_2.Profile.SIP_CONNECT,
|
|
28
|
+
severity: types_2.Severity.ERROR,
|
|
29
|
+
spec: "SIPconnect 1.1, calling party identity (test 1.3.1)",
|
|
30
|
+
summary: "Exactly one P-Asserted-Identity reaches the service provider"
|
|
31
|
+
}, ({ record }, fail) => {
|
|
32
|
+
if (!(0, scope_1.towardServiceProvider)(record))
|
|
33
|
+
return;
|
|
34
|
+
const pai = (0, facts_1.headerValues)((0, facts_1.outbound)(record), "P-Asserted-Identity");
|
|
35
|
+
if (pai.length === 0) {
|
|
36
|
+
return fail("no P-Asserted-Identity on the INVITE to the service provider", "out", "P-Asserted-Identity");
|
|
37
|
+
}
|
|
38
|
+
if (pai.length > 1) {
|
|
39
|
+
return fail(`${pai.length} P-Asserted-Identity headers reach the service provider; it reads the first`, "out", "P-Asserted-Identity");
|
|
40
|
+
}
|
|
41
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster/routr
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Routr.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License");
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
const types_1 = require("../types");
|
|
22
|
+
const types_2 = require("../../types");
|
|
23
|
+
const facts_1 = require("../facts");
|
|
24
|
+
const scope_1 = require("./scope");
|
|
25
|
+
exports.default = (0, types_1.defineRule)({
|
|
26
|
+
id: "sip-connect/privacy",
|
|
27
|
+
profile: types_2.Profile.SIP_CONNECT,
|
|
28
|
+
severity: types_2.Severity.ERROR,
|
|
29
|
+
spec: "RFC 3323 §4.2, RFC 3325 §9.3, SIPconnect 1.1 privacy (test 1.3.4)",
|
|
30
|
+
summary: "With Privacy: id the From is anonymous and the identity travels only in P-Asserted-Identity"
|
|
31
|
+
}, ({ record }, fail) => {
|
|
32
|
+
var _a, _b, _c, _d, _e;
|
|
33
|
+
if (!(0, scope_1.towardServiceProvider)(record))
|
|
34
|
+
return;
|
|
35
|
+
const out = (0, facts_1.outbound)(record);
|
|
36
|
+
const privacy = (0, facts_1.headerValues)(out, "Privacy").join(";").toLowerCase();
|
|
37
|
+
if (!/\bid\b/.test(privacy))
|
|
38
|
+
return;
|
|
39
|
+
const findings = [];
|
|
40
|
+
const from = (_a = out === null || out === void 0 ? void 0 : out.from) === null || _a === void 0 ? void 0 : _a.address;
|
|
41
|
+
const anonymous = ((_c = (_b = from === null || from === void 0 ? void 0 : from.uri) === null || _b === void 0 ? void 0 : _b.user) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === "anonymous" ||
|
|
42
|
+
((_e = (_d = from === null || from === void 0 ? void 0 : from.uri) === null || _d === void 0 ? void 0 : _d.host) === null || _e === void 0 ? void 0 : _e.toLowerCase()) === "anonymous.invalid";
|
|
43
|
+
if (!anonymous) {
|
|
44
|
+
findings.push(fail("Privacy: id requested but From still names the caller", "out", "From"));
|
|
45
|
+
}
|
|
46
|
+
if ((0, facts_1.headerValues)(out, "P-Asserted-Identity").length === 0) {
|
|
47
|
+
findings.push(fail("Privacy: id requested but no P-Asserted-Identity carries the identity for the provider", "out", "P-Asserted-Identity"));
|
|
48
|
+
}
|
|
49
|
+
return findings;
|
|
50
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
5
|
+
* http://github.com/fonoster/routr
|
|
6
|
+
*
|
|
7
|
+
* This file is part of Routr.
|
|
8
|
+
*
|
|
9
|
+
* Licensed under the MIT License (the "License");
|
|
10
|
+
* you may not use this file except in compliance with
|
|
11
|
+
* the License. You may obtain a copy of the License at
|
|
12
|
+
*
|
|
13
|
+
* https://opensource.org/licenses/MIT
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
* See the License for the specific language governing permissions and
|
|
19
|
+
* limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
const types_1 = require("../types");
|
|
22
|
+
const types_2 = require("../../types");
|
|
23
|
+
const facts_1 = require("../facts");
|
|
24
|
+
const scope_1 = require("./scope");
|
|
25
|
+
exports.default = (0, types_1.defineRule)({
|
|
26
|
+
id: "sip-connect/request-uri-e164",
|
|
27
|
+
profile: types_2.Profile.SIP_CONNECT,
|
|
28
|
+
severity: types_2.Severity.ERROR,
|
|
29
|
+
spec: "SIPconnect 1.1, called party number, E.164 with user=phone (test 1.3.1)",
|
|
30
|
+
summary: "The Request-URI to the service provider is E.164 with user=phone"
|
|
31
|
+
}, ({ record }, fail) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
if (!(0, scope_1.towardServiceProvider)(record))
|
|
34
|
+
return;
|
|
35
|
+
const uri = (_a = (0, facts_1.outbound)(record)) === null || _a === void 0 ? void 0 : _a.requestUri;
|
|
36
|
+
if (!uri)
|
|
37
|
+
return;
|
|
38
|
+
if (!(0, facts_1.isE164)(uri.user)) {
|
|
39
|
+
return fail(`Request-URI user ${(_b = uri.user) !== null && _b !== void 0 ? _b : ""} is not E.164`, "out", "Request-URI");
|
|
40
|
+
}
|
|
41
|
+
if (uri.userParam !== "phone") {
|
|
42
|
+
return fail("Request-URI lacks user=phone", "out", "Request-URI");
|
|
43
|
+
}
|
|
44
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TraceRecord } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Whether a record is a dialog-creating INVITE the proxy forwards out of
|
|
4
|
+
* its external interface, which is where SIPconnect 1.1 applies. The
|
|
5
|
+
* external interface is a fact of the EdgePort (externalAddrs); the top
|
|
6
|
+
* Via of the outgoing request names the interface the request leaves by.
|
|
7
|
+
*
|
|
8
|
+
* @param {TraceRecord} r - The record
|
|
9
|
+
* @return {boolean} True when the SIP Connect rules apply
|
|
10
|
+
*/
|
|
11
|
+
export declare function towardServiceProvider(r: TraceRecord): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.towardServiceProvider = towardServiceProvider;
|
|
4
|
+
const facts_1 = require("../facts");
|
|
5
|
+
/**
|
|
6
|
+
* Whether a record is a dialog-creating INVITE the proxy forwards out of
|
|
7
|
+
* its external interface, which is where SIPconnect 1.1 applies. The
|
|
8
|
+
* external interface is a fact of the EdgePort (externalAddrs); the top
|
|
9
|
+
* Via of the outgoing request names the interface the request leaves by.
|
|
10
|
+
*
|
|
11
|
+
* @param {TraceRecord} r - The record
|
|
12
|
+
* @return {boolean} True when the SIP Connect rules apply
|
|
13
|
+
*/
|
|
14
|
+
function towardServiceProvider(r) {
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
if (!(0, facts_1.isForwarded)(r) || r.method !== "INVITE" || (0, facts_1.isInDialog)(r))
|
|
17
|
+
return false;
|
|
18
|
+
return (0, facts_1.isExternalHost)(r.request, (_c = (_b = (_a = (0, facts_1.outbound)(r)) === null || _a === void 0 ? void 0 : _a.via) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.host);
|
|
19
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Finding, Profile, Severity, TraceRecord } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* What a rule sees: the record being evaluated and the earlier records of
|
|
4
|
+
* the same Call-ID, oldest first. In rctl `call` holds the whole file up to
|
|
5
|
+
* this record; in the dispatcher it holds the configured window.
|
|
6
|
+
*/
|
|
7
|
+
export interface RuleContext {
|
|
8
|
+
record: TraceRecord;
|
|
9
|
+
call: TraceRecord[];
|
|
10
|
+
}
|
|
11
|
+
export interface RuleMeta {
|
|
12
|
+
id: string;
|
|
13
|
+
profile: Profile;
|
|
14
|
+
severity: Severity;
|
|
15
|
+
spec: string;
|
|
16
|
+
summary: string;
|
|
17
|
+
}
|
|
18
|
+
/** Builds a finding for the rule being evaluated. */
|
|
19
|
+
export type Fail = (message: string, side?: Finding["side"], header?: string) => Finding;
|
|
20
|
+
export type Check = (ctx: RuleContext, fail: Fail) => Finding | Finding[] | undefined | void;
|
|
21
|
+
export interface Rule extends RuleMeta {
|
|
22
|
+
check: Check;
|
|
23
|
+
}
|
|
24
|
+
export interface EvaluateOptions {
|
|
25
|
+
profiles: Profile[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Declares a rule: its metadata and one pure function over the context.
|
|
29
|
+
*
|
|
30
|
+
* @param {RuleMeta} meta - Id, profile, severity, spec and summary
|
|
31
|
+
* @param {Check} check - Returns the findings, if any
|
|
32
|
+
* @return {Rule} The rule
|
|
33
|
+
*/
|
|
34
|
+
export declare function defineRule(meta: RuleMeta, check: Check): Rule;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineRule = defineRule;
|
|
4
|
+
/**
|
|
5
|
+
* Declares a rule: its metadata and one pure function over the context.
|
|
6
|
+
*
|
|
7
|
+
* @param {RuleMeta} meta - Id, profile, severity, spec and summary
|
|
8
|
+
* @param {Check} check - Returns the findings, if any
|
|
9
|
+
* @return {Rule} The rule
|
|
10
|
+
*/
|
|
11
|
+
function defineRule(meta, check) {
|
|
12
|
+
return Object.assign(Object.assign({}, meta), { check });
|
|
13
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TraceRecord } from "./types";
|
|
2
|
+
export interface Credential {
|
|
3
|
+
username: string;
|
|
4
|
+
password: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SanitizeOptions {
|
|
7
|
+
credentials: Credential[];
|
|
8
|
+
rewrites?: [string, string][];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Thrown when a record carries an Authorization whose username has no
|
|
12
|
+
* test credential: the file would not replay.
|
|
13
|
+
*/
|
|
14
|
+
export declare class UnknownCredentialError extends Error {
|
|
15
|
+
readonly username: string;
|
|
16
|
+
/**
|
|
17
|
+
* @param {string} username - The digest username without a credential
|
|
18
|
+
* @param {number} seq - The record it appears on
|
|
19
|
+
*/
|
|
20
|
+
constructor(username: string, seq: number);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Makes a recording committable as a known-good: every digest response is
|
|
24
|
+
* recomputed with the test password for its username (the digest is
|
|
25
|
+
* stateless, so the record keeps authenticating), then each rewrite is
|
|
26
|
+
* applied to every string so numbers, hosts and addresses stay consistent
|
|
27
|
+
* across the file.
|
|
28
|
+
*
|
|
29
|
+
* @param {TraceRecord} record - A record, redacted or not
|
|
30
|
+
* @param {SanitizeOptions} options - Credentials and rewrites
|
|
31
|
+
* @return {TraceRecord} A sanitized copy
|
|
32
|
+
*/
|
|
33
|
+
export declare function sanitizeRecord(record: TraceRecord, options: SanitizeOptions): TraceRecord;
|
|
34
|
+
/**
|
|
35
|
+
* Reads credentials out of a simpledata credentials.yaml already parsed.
|
|
36
|
+
*
|
|
37
|
+
* @param {unknown} parsed - The parsed YAML (a list of Credentials resources)
|
|
38
|
+
* @return {Credential[]} username and password pairs
|
|
39
|
+
*/
|
|
40
|
+
export declare function credentialsFromResources(parsed: unknown): Credential[];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnknownCredentialError = void 0;
|
|
4
|
+
exports.sanitizeRecord = sanitizeRecord;
|
|
5
|
+
exports.credentialsFromResources = credentialsFromResources;
|
|
6
|
+
/*
|
|
7
|
+
* Copyright (C) 2026 by Fonoster Inc (https://fonoster.com)
|
|
8
|
+
* http://github.com/fonoster/routr
|
|
9
|
+
*
|
|
10
|
+
* This file is part of Routr.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the MIT License (the "License");
|
|
13
|
+
* you may not use this file except in compliance with
|
|
14
|
+
* the License. You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* https://opensource.org/licenses/MIT
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
const auth_1 = require("../auth");
|
|
25
|
+
/**
|
|
26
|
+
* Thrown when a record carries an Authorization whose username has no
|
|
27
|
+
* test credential: the file would not replay.
|
|
28
|
+
*/
|
|
29
|
+
class UnknownCredentialError extends Error {
|
|
30
|
+
/**
|
|
31
|
+
* @param {string} username - The digest username without a credential
|
|
32
|
+
* @param {number} seq - The record it appears on
|
|
33
|
+
*/
|
|
34
|
+
constructor(username, seq) {
|
|
35
|
+
super(`record ${seq}: no credential for digest username "${username}"`);
|
|
36
|
+
this.name = "UnknownCredentialError";
|
|
37
|
+
this.username = username;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.UnknownCredentialError = UnknownCredentialError;
|
|
41
|
+
/**
|
|
42
|
+
* Makes a recording committable as a known-good: every digest response is
|
|
43
|
+
* recomputed with the test password for its username (the digest is
|
|
44
|
+
* stateless, so the record keeps authenticating), then each rewrite is
|
|
45
|
+
* applied to every string so numbers, hosts and addresses stay consistent
|
|
46
|
+
* across the file.
|
|
47
|
+
*
|
|
48
|
+
* @param {TraceRecord} record - A record, redacted or not
|
|
49
|
+
* @param {SanitizeOptions} options - Credentials and rewrites
|
|
50
|
+
* @return {TraceRecord} A sanitized copy
|
|
51
|
+
*/
|
|
52
|
+
function sanitizeRecord(record, options) {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
const copy = JSON.parse(JSON.stringify(record));
|
|
55
|
+
const messages = [copy.request.message, (_a = copy.response) === null || _a === void 0 ? void 0 : _a.message].filter(Boolean);
|
|
56
|
+
messages.forEach((m) => {
|
|
57
|
+
var _a;
|
|
58
|
+
const auth = m.authorization;
|
|
59
|
+
if (!(auth === null || auth === void 0 ? void 0 : auth.username))
|
|
60
|
+
return;
|
|
61
|
+
const cred = options.credentials.find((c) => c.username === auth.username);
|
|
62
|
+
if (!cred)
|
|
63
|
+
throw new UnknownCredentialError(auth.username, record.seq);
|
|
64
|
+
const method = ((_a = auth.method) !== null && _a !== void 0 ? _a : copy.method);
|
|
65
|
+
auth.response = (0, auth_1.calculateAuthResponse)(Object.assign(Object.assign({}, auth), { method }), { username: cred.username, secret: cred.password });
|
|
66
|
+
});
|
|
67
|
+
const rewrites = (_b = options.rewrites) !== null && _b !== void 0 ? _b : [];
|
|
68
|
+
if (!rewrites.length)
|
|
69
|
+
return copy;
|
|
70
|
+
const text = rewrites.reduce((acc, [from, to]) => acc.split(from).join(to), JSON.stringify(copy));
|
|
71
|
+
return JSON.parse(text);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Reads credentials out of a simpledata credentials.yaml already parsed.
|
|
75
|
+
*
|
|
76
|
+
* @param {unknown} parsed - The parsed YAML (a list of Credentials resources)
|
|
77
|
+
* @return {Credential[]} username and password pairs
|
|
78
|
+
*/
|
|
79
|
+
function credentialsFromResources(parsed) {
|
|
80
|
+
if (!Array.isArray(parsed))
|
|
81
|
+
return [];
|
|
82
|
+
return parsed
|
|
83
|
+
.map((r) => { var _a; return (_a = r === null || r === void 0 ? void 0 : r.spec) === null || _a === void 0 ? void 0 : _a.credentials; })
|
|
84
|
+
.filter((c) => !!(c === null || c === void 0 ? void 0 : c.username) && !!(c === null || c === void 0 ? void 0 : c.password));
|
|
85
|
+
}
|