Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
defectdojo_api
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Raul Barreras
defectdojo_api
Commits
9eb0538a
Commit
9eb0538a
authored
7 years ago
by
brianlam38
Browse files
Options
Downloads
Patches
Plain Diff
adding reimport_scan feature and associated unit test
parent
87006a61
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
defectdojo_api/defectdojo.py
+22
-22
22 additions, 22 deletions
defectdojo_api/defectdojo.py
tests/defectdojo_api_unit_test.py
+10
-0
10 additions, 0 deletions
tests/defectdojo_api_unit_test.py
with
32 additions
and
22 deletions
defectdojo_api/defectdojo.py
+
22
−
22
View file @
9eb0538a
...
@@ -668,35 +668,35 @@ class DefectDojoAPI(object):
...
@@ -668,35 +668,35 @@ class DefectDojoAPI(object):
files
=
data
files
=
data
)
)
#####
Credential
API #####
#####
Re-upload
API #####
def
list_credentials
(
self
,
name
=
None
,
username
=
None
,
limit
=
20
):
def
reupload_scan
(
self
,
test_id
,
scan_type
,
file
,
active
,
scan_date
,
tags
=
None
,
build
=
None
):
"""
Re
trieves all the globally configured credentials
.
"""
Re
-uploads and processes a scan file
.
:param name_contains: Search by credential name.
:param test_id: Test identifier.
:param username: Search by username
:param file: Path to the scan file to be uploaded.
:param limit: Number of records to return.
"""
"""
if
tags
is
None
:
tags
=
''
params
=
{}
if
build
is
None
:
if
limit
:
build
=
''
params
[
'
limit
'
]
=
limit
if
name
:
params
[
'
name__contains
'
]
=
name
if
username
:
params
[
'
username__contains
'
]
=
username
return
self
.
_request
(
'
GET
'
,
'
credentials/
'
,
params
)
data
=
{
'
test
'
:
(
''
,
self
.
get_test_uri
(
test_id
)),
'
file
'
:
open
(
file
,
'
rb
'
),
'
scan_type
'
:
(
''
,
scan_type
),
'
active
'
:
(
''
,
active
),
'
scan_date
'
:
(
''
,
scan_date
),
'
tags
'
:
(
''
,
tags
),
'
build_id
'
:
(
''
,
build
)
}
def
get_credential
(
self
,
cred_id
,
limit
=
20
):
return
self
.
_request
(
"""
'
POST
'
,
'
reimportscan/
'
,
Retrieves a credential using the given credential id.
files
=
data
:param credential_id: Credential identification.
)
"""
return
self
.
_request
(
'
GET
'
,
'
credentials/
'
+
str
(
cred_id
)
+
'
/
'
)
##### Credential Mapping API #####
##### Credential Mapping API #####
...
...
This diff is collapsed.
Click to expand it.
tests/defectdojo_api_unit_test.py
+
10
−
0
View file @
9eb0538a
...
@@ -158,5 +158,15 @@ class TestDefectDojoAPI(unittest.TestCase):
...
@@ -158,5 +158,15 @@ class TestDefectDojoAPI(unittest.TestCase):
self
.
assertIsNotNone
(
upload_scan
.
id
())
self
.
assertIsNotNone
(
upload_scan
.
id
())
#### Re-upload API Test ####
def
test_20_reupload_scan
(
self
):
dir_path
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
date
=
datetime
.
now
()
upload_scan
=
self
.
dd
.
upload_scan
(
self
.
__class__
.
test_id
,
"
Burp Scan
"
,
dir_path
+
"
/scans/Bodgeit-burp.xml
"
,
"
true
"
,
date
.
strftime
(
"
%Y/%m/%d
"
),
"
API
"
)
self
.
assertIsNotNone
(
upload_scan
.
id
())
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
unittest
.
main
()
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment