@routr/common 2.17.0 → 2.20.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/errors.d.ts +14 -0
- package/dist/errors.js +19 -1
- package/dist/helper.js +2 -1
- 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,48 @@
|
|
|
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/private-address",
|
|
26
|
+
profile: types_2.Profile.SIP,
|
|
27
|
+
severity: types_2.Severity.WARNING,
|
|
28
|
+
spec: "RFC 3261 §8.1.1.8, RFC 3264 §5",
|
|
29
|
+
summary: "A request leaving through the external interface names no internal address in Contact or SDP"
|
|
30
|
+
}, ({ record }, fail) => {
|
|
31
|
+
var _a, _b, _c, _d, _e, _f;
|
|
32
|
+
if (!(0, facts_1.isForwarded)(record))
|
|
33
|
+
return;
|
|
34
|
+
const out = (0, facts_1.outbound)(record);
|
|
35
|
+
if (!out || !(0, facts_1.isExternalHost)(record.request, (_b = (_a = out.via) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.host))
|
|
36
|
+
return;
|
|
37
|
+
const internal = (host) => !!host && (0, facts_1.isInternalHost)(record.request, host);
|
|
38
|
+
const findings = [];
|
|
39
|
+
const contact = (_e = (_d = (_c = out.contact) === null || _c === void 0 ? void 0 : _c.address) === null || _d === void 0 ? void 0 : _d.uri) === null || _e === void 0 ? void 0 : _e.host;
|
|
40
|
+
if (internal(contact)) {
|
|
41
|
+
findings.push(fail(`Contact names ${contact}, an internal address the far side cannot reach`, "out", "Contact"));
|
|
42
|
+
}
|
|
43
|
+
const c = (_f = /^c=IN IP4 (\S+)/m.exec(out.body || "")) === null || _f === void 0 ? void 0 : _f[1];
|
|
44
|
+
if (internal(c)) {
|
|
45
|
+
findings.push(fail(`SDP connection address ${c} is internal; media needs a relay`, "out", "Body"));
|
|
46
|
+
}
|
|
47
|
+
return findings;
|
|
48
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
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/record-route-self",
|
|
26
|
+
profile: types_2.Profile.SIP,
|
|
27
|
+
severity: types_2.Severity.WARNING,
|
|
28
|
+
spec: "RFC 3261 §16.6 step 4",
|
|
29
|
+
summary: "A Record-Route the proxy adds names one of its own interfaces, and one the far side can reach"
|
|
30
|
+
}, ({ record }, fail) => {
|
|
31
|
+
var _a, _b, _c, _d, _e, _f;
|
|
32
|
+
if (!(0, facts_1.isForwarded)(record) || (0, facts_1.isInDialog)(record))
|
|
33
|
+
return;
|
|
34
|
+
const out = (0, facts_1.outbound)(record);
|
|
35
|
+
const rr = (_d = (_c = (_b = (_a = out === null || out === void 0 ? void 0 : out.recordRoute) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.address) === null || _c === void 0 ? void 0 : _c.uri) === null || _d === void 0 ? void 0 : _d.host;
|
|
36
|
+
if (!rr)
|
|
37
|
+
return;
|
|
38
|
+
if (!(0, facts_1.isOwnHost)(record.request, rr)) {
|
|
39
|
+
return fail(`top Record-Route names ${rr}, not one of the proxy's interfaces`, "out", "Record-Route");
|
|
40
|
+
}
|
|
41
|
+
const via = (_f = (_e = out === null || out === void 0 ? void 0 : out.via) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.host;
|
|
42
|
+
if ((0, facts_1.isExternalHost)(record.request, via) &&
|
|
43
|
+
(0, facts_1.isInternalHost)(record.request, rr)) {
|
|
44
|
+
return fail(`Record-Route names ${rr}, an internal interface, while the request leaves through ${via}`, "out", "Record-Route");
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
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/register-ok",
|
|
26
|
+
profile: types_2.Profile.SIP,
|
|
27
|
+
severity: types_2.Severity.ERROR,
|
|
28
|
+
spec: "RFC 3261 §10.3 step 8",
|
|
29
|
+
summary: "A 200 to REGISTER carries the Contact bound and an expiration (the EdgePort copies the request's Expires)"
|
|
30
|
+
}, ({ record }, fail) => {
|
|
31
|
+
var _a, _b, _c;
|
|
32
|
+
if (!(0, facts_1.isRequest)(record) ||
|
|
33
|
+
record.method !== "REGISTER" ||
|
|
34
|
+
record.outcome !== types_2.TraceOutcome.ANSWERED ||
|
|
35
|
+
(0, facts_1.statusOf)(record) !== 200) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const out = (0, facts_1.outbound)(record);
|
|
39
|
+
if (!(out === null || out === void 0 ? void 0 : out.contact)) {
|
|
40
|
+
return fail("200 to REGISTER carries no Contact", "out", "Contact");
|
|
41
|
+
}
|
|
42
|
+
const inMsg = (0, facts_1.inbound)(record);
|
|
43
|
+
const candidates = [
|
|
44
|
+
(_a = out.expires) === null || _a === void 0 ? void 0 : _a.expires,
|
|
45
|
+
out.contact.expires,
|
|
46
|
+
(_b = inMsg.expires) === null || _b === void 0 ? void 0 : _b.expires,
|
|
47
|
+
(_c = inMsg.contact) === null || _c === void 0 ? void 0 : _c.expires
|
|
48
|
+
];
|
|
49
|
+
if (!candidates.some((e) => typeof e === "number" && e >= 0)) {
|
|
50
|
+
return fail("200 to REGISTER carries no expiration and the request had none", "out", "Expires");
|
|
51
|
+
}
|
|
52
|
+
});
|
|
@@ -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
|
+
}
|