Add backend support for specifying target type [RUN ALL RSPEC] [RUN AS-IF-FOSS]
requested to merge philipcunningham-add-backend-for-specifying-target-type-for-on-demand-294060 into master
What does this MR do?
adds the ability to set target_type
on DastSiteProfile
and retrieve the value via GraphQL.
Why?
we want to give users of dast
on-demand scans the ability to run api scans.
Related Issue(s)
GraphQL
enable the feature in the rails console with:
Feature.enable(:security_dast_site_profiles_api_option)
Query
{
project(fullPath: "root/on-demand-scans") {
dastSiteProfiles(first: 3) {
nodes {
id
targetType
}
}
}
}
Mutation
query:
mutation($dastSiteProfileCreateInput: DastSiteProfileCreateInput!) {
dastSiteProfileCreate(input: $dastSiteProfileCreateInput) {
clientMutationId
errors
id
}
}
variables:
{
"dastSiteProfileCreateInput": {
"fullPath": "namespace1/project1",
"profileName": "Total impactful access",
"targetUrl": "http://example1.test",
"targetType": "API",
"excludedUrls": [
"http://example1.test/logout"
],
"requestHeaders": "Authorization: secret",
"auth": {
"enabled": true,
"url": "http://example1.test/login",
"usernameField": "session[username]",
"passwordField": "session[password]",
"username": "user3@example.org",
"password": "24156abc1b46755ca3a2a2ffa566ea9b"
}
}
}
Database
% rails db:migrate:up VERSION=20210407002511 && rails db:migrate:down VERSION=20210407002511
== 20210407002511 AddTypeToDastSiteProfile: migrating =========================
-- add_column(:dast_site_profiles, :target_type, :integer, {:limit=>2, :default=>0, :null=>false})
-> 0.0073s
== 20210407002511 AddTypeToDastSiteProfile: migrated (0.0073s) ================
== 20210407002511 AddTypeToDastSiteProfile: reverting =========================
-- remove_column(:dast_site_profiles, :target_type, :integer, {:limit=>2, :default=>0, :null=>false})
-> 0.0034s
== 20210407002511 AddTypeToDastSiteProfile: reverted (0.0057s) ================
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because _____.
-
-
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Philip Cunningham