Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #184 from Bidaya0/feature/issue-4
Browse files Browse the repository at this point in the history
update openapi
  • Loading branch information
Bidaya0 committed Nov 9, 2021
2 parents 411f1f1 + 6402302 commit cc91e06
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 10 deletions.
83 changes: 83 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: 🐛 Bug report
description: Report a bug to help us improve DongTai
title: "[Bug]: "
labels: [bug]
assignees:
- exexute
body:
- type: markdown
attributes:
value: |
Thank you for submitting a bug report!
Please fill out the template below to make it easier to debug your problem.
If you are not sure if it is a bug or not, you can contact us via the available [support channels](https://github.com/HXSecurity/DongTai/issues/new/choose).
- type: checkboxes
attributes:
label: Preflight Checklist
description: Please ensure you've completed all of the following.
options:
- label: I agree to follow the [Code of Conduct](https://github.com/HXSecurity/DongTai/blob/main/.github/CODE_OF_CONDUCT.md) that this project adheres to.
required: true
- label: I have searched the [issue tracker](https://www.github.com/HXSecurity/DongTai/issues) for an issue that matches the one I want to file, without success.
required: true
- label: I am not looking for support or already pursued the available [support channels](https://github.com/HXSecurity/DongTai/issues/new/choose) without success.
required: true
- type: input
attributes:
label: Version
description: What version of DongTai are you running?
placeholder: 1.0.0
validations:
required: true
- type: dropdown
attributes:
label: Installation Type
description: How did you install DongTai?
options:
- Official SaaS Service
- Official Kubernetes
- Official Docker Compose
- Other (specify below)
validations:
required: true
- type: dropdown
attributes:
label: Service Name
description: Which service do you want to report the bug?
options:
- Doc(DongTai-Doc)
- Docker(DongTai-Base-Image)
- Deploy(DongTai-deploy)
- DongTai-Web
- DongTai-WebAPI
- DongTai-OpenAPI
- DongTai-Engine
- DongTai-Core
- DongTai-agent-python
- DongTai-agent-java
- DongTai-agent-php
multiple: true
validations:
required: true
- type: textarea
attributes:
label: Describe the details of the bug and the steps to reproduce it
description: Steps to reproduce the behavior if it is not self-explanatory.
placeholder: |
1. In this environment...
2. With this config...
3. Do something...
4. See error...
validations:
required: true
- type: textarea
attributes:
label: Additional Information
description: Links? References? Anything that will give us more context about the issue that you are encountering!
- type: textarea
attributes:
label: Logs
description: Dex application logs (if relevant).
render: shell
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
blank_issues_enabled: false
contact_links:
- name: 🐛 Bug report
url: https://github.com/HXSecurity/DongTai/issues/new?assignees=exexute,bidaya0&labels=bug&projects=1&template=bug_report.yaml
url: https://github.com/HXSecurity/DongTai-webapi/issues/new?assignees=exexute,bidaya0&labels=bug&projects=1&template=bug_report.yaml
about: Report a bug to help us improve DongTai

- name: 🚀 Feature request
url: https://github.com/HXSecurity/DongTai/issues/new?assignees=exexute,bidaya0&labels=feature&projects=1&template=feature_request.yaml
url: https://github.com/HXSecurity/DongTai-webapi/issues/new?assignees=exexute,bidaya0&labels=feature&projects=1&template=feature_request.yaml
about: Suggest an idea for DongTai

- name: ❓ Ask a question
Expand Down
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: 🚀 Feature request
description: Suggest an idea for DongTai
title: "[Feature]: "
labels: [feature, ]
assignees:
- exexute
body:
- type: markdown
attributes:
value: |
Thank you for submitting a feature request!
Please describe what you would like to change/add and why in detail by filling out the template below.
If you are not sure if your request fits into DongTai, you can contact us via the available [support channels](https://github.com/HXSecurity/DongTai/issues/new/choose).
- type: checkboxes
attributes:
label: Preflight Checklist
description: Please ensure you've completed all of the following.
options:
- label: I agree to follow the [Code of Conduct](https://github.com/HXSecurity/DongTai/blob/main/.github/CODE_OF_CONDUCT.md) that this project adheres to.
required: true
- label: I have searched the [issue tracker](https://www.github.com/HXSecurity/DongTai/issues) for an issue that matches the one I want to file, without success.
required: true
- type: textarea
attributes:
label: Problem Description
description: A clear and concise description of the problem you are seeking to solve with this feature request.
validations:
required: true
- type: textarea
attributes:
label: Proposed Solution
description: A clear and concise description of what would you like to happen.
validations:
required: true
- type: textarea
attributes:
label: Alternatives Considered
description: A clear and concise description of any alternative solutions or features you've considered.
- type: textarea
attributes:
label: Additional Information
description: Add any other context about the problem here.
13 changes: 8 additions & 5 deletions iast/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from dongtai.models.api_route import IastApiRoute, IastApiMethod, IastApiRoute, HttpMethod, IastApiResponse, IastApiMethodHttpMethodRelation
from dongtai.models.agent_method_pool import MethodPool
from rest_framework.serializers import Serializer

from webapi.settings import OPENAPI

def get_model_field(model, exclude=[], include=[]):
fields = [field.name for field in model._meta.fields]
Expand Down Expand Up @@ -214,16 +214,19 @@ def apiroute_cachekey(api_route, agents, http_method=None):
def sha1(string, encoding='utf-8'):
return hashlib.sha1(string.encode(encoding)).hexdigest()
from dongtai.models.profile import IastProfile


def get_openapi():
profilefromdb = IastProfile.objects.filter(
key='apiserver').values_list('value', flat=True).first()
profilefromini = None
profilefromdb = IastProfile.objects.filter(key='apiserver').values_list(
'value', flat=True).first()
profilefromini = OPENAPI
profiles = list(
filter(lambda x: x is not None, [profilefromdb, profilefromini]))
filter(lambda x: x is not None, [profilefromini, profilefromdb]))
if profiles == []:
return None
return profiles[0]


from urllib.parse import urlparse

def validate_url(url):
Expand Down
5 changes: 3 additions & 2 deletions iast/views/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from iast.utils import extend_schema_with_envcheck, get_response_serializer
from urllib.parse import urlparse
from rest_framework import serializers
from iast.utils import get_openapi

_PostResponseSerializer = get_response_serializer(status_msg_keypair=(
((201, _('Created success')), ''),
Expand Down Expand Up @@ -42,10 +43,10 @@ def get(self, request):
key='apiserver').values_list('value', flat=True).first()
profilefromini = None
profiles = list(
filter(lambda x: x is not None, [profilefromdb, profilefromini]))
filter(lambda x: x is not None, [profilefromini, profilefromdb]))
if profiles == [] or not profiles[0]:
return R.failure(msg=_("Get OpenAPI configuration failed"))
return R.success(data={'url': profiles[0]})
return R.success(data={'url': get_openapi()})

@extend_schema_with_envcheck(
request=OpenApiEndpointSerializer,
Expand Down
3 changes: 2 additions & 1 deletion webapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def ranstr(num):
'use_unicode': True,
},
}
}
}
}
CACHES = {
'default': {
Expand Down Expand Up @@ -293,6 +293,7 @@ def ranstr(num):
'HOST': config.get("engine", 'url'),
}

OPENAPI = config.get("apiserver", "url")

# notify
EMAIL_SERVER = config.get('smtp', 'server')
Expand Down

0 comments on commit cc91e06

Please sign in to comment.