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
8efa247b
Commit
8efa247b
authored
Apr 12, 2021
by
Dheeraj Joshi
Committed by
David O'Regan
Apr 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve UX for redacted fields in DAST Profiles
parent
42954bd5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
29 deletions
+42
-29
ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/components/dast_site_auth_section.vue
..._site_profiles_form/components/dast_site_auth_section.vue
+0
-6
ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/components/dast_site_profile_form.vue
..._site_profiles_form/components/dast_site_profile_form.vue
+23
-10
ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/constants.js
...curity_configuration/dast_site_profiles_form/constants.js
+2
-0
ee/app/presenters/dast/site_profile_presenter.rb
ee/app/presenters/dast/site_profile_presenter.rb
+1
-1
ee/spec/frontend/security_configuration/dast_site_profiles_form/components/dast_site_profile_form_spec.js
...e_profiles_form/components/dast_site_profile_form_spec.js
+15
-11
ee/spec/graphql/types/dast_site_profile_type_spec.rb
ee/spec/graphql/types/dast_site_profile_type_spec.rb
+1
-1
No files found.
ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/components/dast_site_auth_section.vue
View file @
8efa247b
...
@@ -60,11 +60,6 @@ export default {
...
@@ -60,11 +60,6 @@ export default {
isSensitiveFieldRequired
:
!
isEditMode
,
isSensitiveFieldRequired
:
!
isEditMode
,
};
};
},
},
computed
:
{
passwordFieldPlaceholder
()
{
return
this
.
isEditMode
?
'
••••••••
'
:
''
;
},
},
watch
:
{
watch
:
{
form
:
{
handler
:
'
emitUpdate
'
,
immediate
:
true
,
deep
:
true
},
form
:
{
handler
:
'
emitUpdate
'
,
immediate
:
true
,
deep
:
true
},
},
},
...
@@ -128,7 +123,6 @@ export default {
...
@@ -128,7 +123,6 @@ export default {
autocomplete=
"off"
autocomplete=
"off"
name=
"password"
name=
"password"
type=
"password"
type=
"password"
:placeholder=
"passwordFieldPlaceholder"
:required=
"isSensitiveFieldRequired"
:required=
"isSensitiveFieldRequired"
:state=
"form.fields.password.state"
:state=
"form.fields.password.state"
/>
/>
...
...
ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/components/dast_site_profile_form.vue
View file @
8efa247b
...
@@ -21,6 +21,8 @@ import {
...
@@ -21,6 +21,8 @@ import {
MAX_CHAR_LIMIT_EXCLUDED_URLS
,
MAX_CHAR_LIMIT_EXCLUDED_URLS
,
MAX_CHAR_LIMIT_REQUEST_HEADERS
,
MAX_CHAR_LIMIT_REQUEST_HEADERS
,
EXCLUDED_URLS_SEPARATOR
,
EXCLUDED_URLS_SEPARATOR
,
REDACTED_PASSWORD
,
REDACTED_REQUEST_HEADERS
,
}
from
'
../constants
'
;
}
from
'
../constants
'
;
import
dastSiteProfileCreateMutation
from
'
../graphql/dast_site_profile_create.mutation.graphql
'
;
import
dastSiteProfileCreateMutation
from
'
../graphql/dast_site_profile_create.mutation.graphql
'
;
import
dastSiteProfileUpdateMutation
from
'
../graphql/dast_site_profile_update.mutation.graphql
'
;
import
dastSiteProfileUpdateMutation
from
'
../graphql/dast_site_profile_update.mutation.graphql
'
;
...
@@ -61,7 +63,8 @@ export default {
...
@@ -61,7 +63,8 @@ export default {
},
},
},
},
data
()
{
data
()
{
const
{
name
=
''
,
targetUrl
=
''
,
excludedUrls
=
[],
auth
=
{}
}
=
this
.
siteProfile
||
{};
const
{
name
=
''
,
targetUrl
=
''
,
excludedUrls
=
[],
requestHeaders
=
''
,
auth
=
{}
}
=
this
.
siteProfile
||
{};
const
form
=
{
const
form
=
{
state
:
false
,
state
:
false
,
...
@@ -75,7 +78,7 @@ export default {
...
@@ -75,7 +78,7 @@ export default {
skipValidation
:
true
,
skipValidation
:
true
,
}),
}),
requestHeaders
:
initFormField
({
requestHeaders
:
initFormField
({
value
:
''
,
value
:
requestHeaders
||
''
,
required
:
false
,
required
:
false
,
skipValidation
:
true
,
skipValidation
:
true
,
}),
}),
...
@@ -131,10 +134,8 @@ export default {
...
@@ -131,10 +134,8 @@ export default {
tooltip
:
s__
(
tooltip
:
s__
(
'
DastProfiles|Request header names and values. Headers are added to every request made by DAST.
'
,
'
DastProfiles|Request header names and values. Headers are added to every request made by DAST.
'
,
),
),
placeholder
:
this
.
hasRequestHeaders
// eslint-disable-next-line @gitlab/require-i18n-strings
?
__
(
'
[Redacted]
'
)
placeholder
:
'
Cache-control: no-cache, User-Agent: DAST/1.0
'
,
:
// eslint-disable-next-line @gitlab/require-i18n-strings
'
Cache-control: no-cache, User-Agent: DAST/1.0
'
,
},
},
};
};
},
},
...
@@ -149,6 +150,14 @@ export default {
...
@@ -149,6 +150,14 @@ export default {
.
split
(
EXCLUDED_URLS_SEPARATOR
)
.
split
(
EXCLUDED_URLS_SEPARATOR
)
.
map
((
url
)
=>
url
.
trim
());
.
map
((
url
)
=>
url
.
trim
());
},
},
serializedAuthFields
()
{
const
authFields
=
serializeFormObject
(
this
.
authSection
.
fields
);
// not to send password value if unchanged
if
(
authFields
.
password
===
REDACTED_PASSWORD
)
{
delete
authFields
.
password
;
}
return
authFields
;
},
},
},
methods
:
{
methods
:
{
onSubmit
()
{
onSubmit
()
{
...
@@ -166,7 +175,9 @@ export default {
...
@@ -166,7 +175,9 @@ export default {
this
.
hideErrors
();
this
.
hideErrors
();
const
{
errorMessage
}
=
this
.
i18n
;
const
{
errorMessage
}
=
this
.
i18n
;
const
{
profileName
,
targetUrl
,
...
additionalFields
}
=
serializeFormObject
(
this
.
form
.
fields
);
const
{
profileName
,
targetUrl
,
requestHeaders
,
excludedUrls
}
=
serializeFormObject
(
this
.
form
.
fields
,
);
const
variables
=
{
const
variables
=
{
input
:
{
input
:
{
...
@@ -175,11 +186,13 @@ export default {
...
@@ -175,11 +186,13 @@ export default {
profileName
,
profileName
,
targetUrl
,
targetUrl
,
...(
this
.
glFeatures
.
securityDastSiteProfilesAdditionalFields
&&
{
...(
this
.
glFeatures
.
securityDastSiteProfilesAdditionalFields
&&
{
...
additionalFields
,
auth
:
this
.
serializedAuthFields
,
auth
:
serializeFormObject
(
this
.
authSection
.
fields
),
...(
excludedUrls
&&
{
...(
additionalFields
.
excludedUrls
&&
{
excludedUrls
:
this
.
parsedExcludedUrls
,
excludedUrls
:
this
.
parsedExcludedUrls
,
}),
}),
...(
requestHeaders
!==
REDACTED_REQUEST_HEADERS
&&
{
requestHeaders
,
}),
}),
}),
},
},
};
};
...
...
ee/app/assets/javascripts/security_configuration/dast_site_profiles_form/constants.js
View file @
8efa247b
export
const
MAX_CHAR_LIMIT_EXCLUDED_URLS
=
2048
;
export
const
MAX_CHAR_LIMIT_EXCLUDED_URLS
=
2048
;
export
const
MAX_CHAR_LIMIT_REQUEST_HEADERS
=
2048
;
export
const
MAX_CHAR_LIMIT_REQUEST_HEADERS
=
2048
;
export
const
EXCLUDED_URLS_SEPARATOR
=
'
,
'
;
export
const
EXCLUDED_URLS_SEPARATOR
=
'
,
'
;
export
const
REDACTED_PASSWORD
=
'
••••••••
'
;
export
const
REDACTED_REQUEST_HEADERS
=
'
••••••••
'
;
ee/app/presenters/dast/site_profile_presenter.rb
View file @
8efa247b
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
module
Dast
module
Dast
class
SiteProfilePresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
class
SiteProfilePresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
REDACTED_PASSWORD
=
'••••••••'
REDACTED_PASSWORD
=
'••••••••'
REDACTED_REQUEST_HEADERS
=
'
[Redacted]
'
REDACTED_REQUEST_HEADERS
=
'
••••••••
'
presents
:site_profile
presents
:site_profile
...
...
ee/spec/frontend/security_configuration/dast_site_profiles_form/components/dast_site_profile_form_spec.js
View file @
8efa247b
...
@@ -186,30 +186,34 @@ describe('DastSiteProfileForm', () => {
...
@@ -186,30 +186,34 @@ describe('DastSiteProfileForm', () => {
expect
(
findRequestHeadersInput
().
attributes
(
'
maxlength
'
)).
toBe
(
'
2048
'
);
expect
(
findRequestHeadersInput
().
attributes
(
'
maxlength
'
)).
toBe
(
'
2048
'
);
});
});
describe
(
'
should have correct placeholders
'
,
()
=>
{
describe
(
'
request-headers and password fields renders correctly
'
,
()
=>
{
const
defaultPlaceholder
=
'
Cache-control: no-cache, User-Agent: DAST/1.0
'
;
it
(
'
when creating a new profile
'
,
async
()
=>
{
it
(
'
when creating a new profile
'
,
async
()
=>
{
expect
(
findRequestHeadersInput
().
attributes
(
'
placeholder
'
)).
toBe
(
defaultPlaceholder
);
expect
(
findRequestHeadersInput
().
attributes
(
'
placeholder
'
)).
toBe
(
'
Cache-control: no-cache, User-Agent: DAST/1.0
'
,
);
expect
(
findRequestHeadersInput
().
element
.
value
).
toBe
(
''
);
expect
(
findByNameAttribute
(
'
password
'
).
exists
()).
toBe
(
false
);
});
});
it
(
'
when updating an existing profile
with no request headers set
'
,
()
=>
{
it
(
'
when updating an existing profile
'
,
()
=>
{
createFullComponent
({
createFullComponent
({
propsData
:
{
propsData
:
{
siteProfile
:
{
...
siteProfileOne
,
requestHeaders
:
''
}
,
siteProfile
:
siteProfileOne
,
},
},
});
});
expect
(
findRequestHeadersInput
().
attributes
(
'
placeholder
'
)).
toBe
(
defaultPlaceholder
);
expect
(
findRequestHeadersInput
().
element
.
value
).
toBe
(
siteProfileOne
.
requestHeaders
);
expect
(
findByNameAttribute
(
'
password
'
).
element
.
value
).
toBe
(
siteProfileOne
.
auth
.
password
);
});
});
it
(
'
when updating an existing profile
'
,
()
=>
{
it
(
'
when updating an existing profile
with no request-header & password
'
,
()
=>
{
createFullComponent
({
createFullComponent
({
propsData
:
{
propsData
:
{
siteProfile
:
siteProfileOne
,
siteProfile
:
{
...
siteProfileOne
,
requestHeaders
:
null
,
auth
:
{
enabled
:
true
}
}
,
},
},
});
});
expect
(
findRequestHeadersInput
().
attributes
(
'
placeholder
'
)).
toBe
(
'
[Redacted]
'
);
expect
(
findRequestHeadersInput
().
element
.
value
).
toBe
(
'
'
);
expect
(
findByNameAttribute
(
'
password
'
).
attributes
(
'
placeholder
'
)).
toBe
(
'
••••••••
'
);
expect
(
findByNameAttribute
(
'
password
'
).
element
.
value
).
toBe
(
'
'
);
});
});
});
});
});
});
...
...
ee/spec/graphql/types/dast_site_profile_type_spec.rb
View file @
8efa247b
...
@@ -99,7 +99,7 @@ RSpec.describe GitlabSchema.types['DastSiteProfile'] do
...
@@ -99,7 +99,7 @@ RSpec.describe GitlabSchema.types['DastSiteProfile'] do
it
'is redacted'
do
it
'is redacted'
do
create
(
:dast_site_profile_secret_variable
,
dast_site_profile:
object
,
key:
Dast
::
SiteProfileSecretVariable
::
REQUEST_HEADERS
)
create
(
:dast_site_profile_secret_variable
,
dast_site_profile:
object
,
key:
Dast
::
SiteProfileSecretVariable
::
REQUEST_HEADERS
)
expect
(
resolve_field
(
:request_headers
,
object
,
current_user:
user
)).
to
eq
(
'
[Redacted]
'
)
expect
(
resolve_field
(
:request_headers
,
object
,
current_user:
user
)).
to
eq
(
'
••••••••
'
)
end
end
end
end
end
end
...
...
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