Skip to content

Commit e638e41

Browse files
authored
Merge pull request #56 from ricekot/add-graphql
Add GraphQL API
2 parents 9bab9bf + 1986cd4 commit e638e41

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
55

66
## [Unreleased]
7+
### Added
8+
- Add API for GraphQL add-on, version 0.2.0.
79

810
### Changed
911
- Fix typos in error messages.

src/zapv2/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
from .core import core
4040
from .exportreport import exportreport
4141
from .forcedUser import forcedUser
42+
from .graphql import graphql
4243
from .httpSessions import httpSessions
4344
from .importLogFiles import importLogFiles
4445
from .importurls import importurls
@@ -101,6 +102,7 @@ def __init__(self, proxies=None, apikey=None, validate_status_code=False):
101102
self.core = core(self)
102103
self.exportreport = exportreport(self)
103104
self.forcedUser = forcedUser(self)
105+
self.graphql = graphql(self)
104106
self.httpsessions = httpSessions(self)
105107
self.importLogFiles = importLogFiles(self)
106108
self.importurls = importurls(self)

src/zapv2/graphql.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Zed Attack Proxy (ZAP) and its related class files.
2+
#
3+
# ZAP is an HTTP/HTTPS proxy for assessing web application security.
4+
#
5+
# Copyright 2020 the ZAP development team
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
"""
19+
This file was automatically generated.
20+
"""
21+
22+
import six
23+
24+
25+
class graphql(object):
26+
27+
def __init__(self, zap):
28+
self.zap = zap
29+
30+
def import_file(self, endurl, file, apikey=''):
31+
"""
32+
Imports a GraphQL Schema from a File.
33+
This component is optional and therefore the API will only work if it is installed
34+
"""
35+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'graphql/action/importFile/', {'endurl': endurl, 'file': file, 'apikey': apikey})))
36+
37+
def import_url(self, endurl, url=None, apikey=''):
38+
"""
39+
Imports a GraphQL Schema from a URL.
40+
This component is optional and therefore the API will only work if it is installed
41+
"""
42+
params = {'endurl': endurl, 'apikey': apikey}
43+
if url is not None:
44+
params['url'] = url
45+
return six.next(six.itervalues(self.zap._request(self.zap.base + 'graphql/action/importUrl/', params)))

0 commit comments

Comments
 (0)