Skip to content

Add GraphQL API #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [Unreleased]
### Added
- Add API for GraphQL add-on, version 0.2.0.

### Changed
- Fix typos in error messages.
Expand Down
2 changes: 2 additions & 0 deletions src/zapv2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from .core import core
from .exportreport import exportreport
from .forcedUser import forcedUser
from .graphql import graphql
from .httpSessions import httpSessions
from .importLogFiles import importLogFiles
from .importurls import importurls
Expand Down Expand Up @@ -101,6 +102,7 @@ def __init__(self, proxies=None, apikey=None, validate_status_code=False):
self.core = core(self)
self.exportreport = exportreport(self)
self.forcedUser = forcedUser(self)
self.graphql = graphql(self)
self.httpsessions = httpSessions(self)
self.importLogFiles = importLogFiles(self)
self.importurls = importurls(self)
Expand Down
45 changes: 45 additions & 0 deletions src/zapv2/graphql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Zed Attack Proxy (ZAP) and its related class files.
#
# ZAP is an HTTP/HTTPS proxy for assessing web application security.
#
# Copyright 2020 the ZAP development team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
This file was automatically generated.
"""

import six


class graphql(object):

def __init__(self, zap):
self.zap = zap

def import_file(self, endurl, file, apikey=''):
"""
Imports a GraphQL Schema from a File.
This component is optional and therefore the API will only work if it is installed
"""
return six.next(six.itervalues(self.zap._request(self.zap.base + 'graphql/action/importFile/', {'endurl': endurl, 'file': file, 'apikey': apikey})))

def import_url(self, endurl, url=None, apikey=''):
"""
Imports a GraphQL Schema from a URL.
This component is optional and therefore the API will only work if it is installed
"""
params = {'endurl': endurl, 'apikey': apikey}
if url is not None:
params['url'] = url
return six.next(six.itervalues(self.zap._request(self.zap.base + 'graphql/action/importUrl/', params)))