• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geosolutions-it / MapStore2 / 18905443415

29 Oct 2025 10:53AM UTC coverage: 76.91% (-0.01%) from 76.92%
18905443415

Pull #11333

github

web-flow
Merge 0b51ae1f4 into f5928b825
Pull Request #11333: Grant access to MapStore resources by IP #972

32037 of 49767 branches covered (64.37%)

74 of 104 new or added lines in 4 files covered. (71.15%)

1 existing line in 1 file now uncovered.

39814 of 51767 relevant lines covered (76.91%)

37.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.45
/web/client/utils/IPValidationUtils.js
1
/*
2
 * Copyright 2025, GeoSolutions Sas.
3
 * All rights reserved.
4
 *
5
 * This source code is licensed under the BSD-style license found in the
6
 * LICENSE file in the root directory of this source tree.
7
 */
8

9
/**
10
 * Validates an IP address in CIDR notation (required format)
11
 * @param {string} ipAddress - The IP address in CIDR notation (e.g., "192.168.1.1/32" or "192.168.1.0/24")
12
 * @returns {object} - Returns { isValid: boolean, error: string|null } where error is a translation key
13
 */
14
export function validateIPAddress(ipAddress) {
15
    if (!ipAddress || typeof ipAddress !== 'string') {
24✔
16
        return { isValid: false, error: 'ipManager.validation.ipRequired' };
3✔
17
    }
18

19
    // Trim whitespace
20
    const trimmedIP = ipAddress.trim();
21✔
21

22
    if (!trimmedIP) {
21!
NEW
23
        return { isValid: false, error: 'ipManager.validation.ipRequired' };
×
24
    }
25

26
    // CIDR notation is required (IP/mask)
27
    const parts = trimmedIP.split('/');
21✔
28

29
    // Must have exactly 2 parts: IP and mask
30
    if (parts.length !== 2) {
21✔
31
        return { isValid: false, error: 'ipManager.validation.cidrRequired' };
3✔
32
    }
33

34
    // Validate CIDR notation: IP/mask
35
    const ip = parts[0].trim();
18✔
36
    const maskStr = parts[1].trim();
18✔
37
    const mask = parseInt(maskStr, 10);
18✔
38

39
    // Validate mask
40
    if (maskStr === '' || isNaN(mask) || mask < 0 || mask > 32) {
18✔
41
        return { isValid: false, error: 'ipManager.validation.invalidMask' };
5✔
42
    }
43

44
    // Validate IP address format
45
    const ipParts = ip.split('.');
13✔
46
    if (ipParts.length !== 4) {
13✔
47
        return { isValid: false, error: 'ipManager.validation.invalidFormat' };
2✔
48
    }
49

50
    for (let i = 0; i < 4; i++) {
11✔
51
        const octetStr = ipParts[i].trim();
38✔
52
        const octet = parseInt(octetStr, 10);
38✔
53
        if (octetStr === '' || isNaN(octet) || octet < 0 || octet > 255) {
38✔
54
            return { isValid: false, error: 'ipManager.validation.invalidOctet' };
4✔
55
        }
56
    }
57

58
    return { isValid: true, error: null };
7✔
59
}
60

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc