Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2d8de8ea
Commit
2d8de8ea
authored
Aug 17, 2020
by
peterhegman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move ip address integer check to main validator
It was confirmed that we also want this check for Geo settings
parent
a93172ee
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
16 deletions
+18
-16
ee/app/assets/javascripts/groups/settings/access_restriction_field/validate_ip_address.js
.../settings/access_restriction_field/validate_ip_address.js
+1
-3
ee/app/assets/javascripts/validators/ip_address.js
ee/app/assets/javascripts/validators/ip_address.js
+6
-0
ee/spec/frontend/groups/settings/access_restriction_field/validate_ip_address_spec.js
...ings/access_restriction_field/validate_ip_address_spec.js
+0
-13
ee/spec/frontend/validators/ip_address_spec.js
ee/spec/frontend/validators/ip_address_spec.js
+11
-0
No files found.
ee/app/assets/javascripts/groups/settings/access_restriction_field/validate_ip_address.js
View file @
2d8de8ea
...
...
@@ -2,9 +2,7 @@ import validateIpAddress from 'ee/validators/ip_address';
import
{
__
,
sprintf
}
from
'
~/locale
'
;
export
default
address
=>
{
// Reject IP addresses that are only integers to match Ruby IPAddr
// https://github.com/whitequark/ipaddr.js/issues/7#issuecomment-158545695
if
(
/^
\d
+$/
.
exec
(
address
)
||
!
validateIpAddress
(
address
))
{
if
(
!
validateIpAddress
(
address
))
{
return
sprintf
(
__
(
'
%{address} is an invalid IP address range
'
),
{
address
},
false
);
}
...
...
ee/app/assets/javascripts/validators/ip_address.js
View file @
2d8de8ea
import
ipaddr
from
'
ipaddr.js
'
;
export
default
address
=>
{
// Reject IP addresses that are only integers to match Ruby IPAddr
// https://github.com/whitequark/ipaddr.js/issues/7#issuecomment-158545695
if
(
/^
\d
+$/
.
exec
(
address
))
{
return
false
;
}
try
{
// Checks if Valid IPv4/IPv6 (CIDR) - Throws if not
return
Boolean
(
ipaddr
.
parseCIDR
(
address
));
...
...
ee/spec/frontend/groups/settings/access_restriction_field/validate_ip_address_spec.js
View file @
2d8de8ea
...
...
@@ -2,19 +2,6 @@ import * as validateIpAddress from 'ee/validators/ip_address';
import
validateRestrictedIpAddress
from
'
ee/groups/settings/access_restriction_field/validate_ip_address
'
;
describe
(
'
validateRestrictedIpAddress
'
,
()
=>
{
describe
(
'
when IP address is only integers
'
,
()
=>
{
it
.
each
`
address
${
1
}
${
19
}
${
192
}
`
(
'
$address - returns an error message
'
,
({
address
})
=>
{
expect
(
validateRestrictedIpAddress
(
address
)).
toBe
(
`
${
address
}
is an invalid IP address range`
,
);
});
});
describe
(
'
when `validateIpAddress` returns false
'
,
()
=>
{
it
(
'
returns an error message
'
,
()
=>
{
validateIpAddress
.
default
=
jest
.
fn
(()
=>
false
);
...
...
ee/spec/frontend/validators/ip_address_spec.js
View file @
2d8de8ea
...
...
@@ -2,6 +2,17 @@ import ipaddr from 'ipaddr.js';
import
validateIpAddress
from
'
ee/validators/ip_address
'
;
describe
(
'
validateIpAddress
'
,
()
=>
{
describe
(
'
when IP address is only integers
'
,
()
=>
{
it
.
each
`
address
${
1
}
${
19
}
${
192
}
`
(
'
$address - returns false
'
,
({
address
})
=>
{
expect
(
validateIpAddress
(
address
)).
toBe
(
false
);
});
});
describe
(
'
when IP address is in valid CIDR format
'
,
()
=>
{
it
(
'
returns true
'
,
()
=>
{
ipaddr
.
parseCIDR
=
jest
.
fn
(()
=>
[
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment