-
Notifications
You must be signed in to change notification settings - Fork 162
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
Enhanced Target Server Validator #715
Merged
danistrebel
merged 10 commits into
apigee:main
from
payaljindal:update/target-server-validator
Jan 24, 2024
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4bf4115
feat: request payload converted to json & added json threat protectio…
payaljindal 0131a34
fix: fixed _cached_hosts issue
payaljindal 75ad51c
feat: added run_parallel functions and logger for logging
payaljindal 3b0dcc5
fix: fixed the target proxy Apigee type
payaljindal 5b5b4e5
fix: deleted jar files and updated dependencies
payaljindal 4f0be35
fix: updated library to gson
payaljindal ac590b6
Merge branch 'main' into update/target-server-validator
payaljindal 4420b15
chore: added licenseheaders
payaljindal 1db14cc
fix: added venv in pipeline.sh
payaljindal 83f4c98
fix: removed csv headers from read rows
payaljindal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
tools/target-server-validator/apiproxy/policies/JSON-Threat-Protection.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<JSONThreatProtection continueOnError="false" enabled="true" name="JSON-Threat-Protection"> | ||
<DisplayName>JSON Threat Protection</DisplayName> | ||
<Properties/> | ||
<ArrayElementCount>5</ArrayElementCount> | ||
<Source>request</Source> | ||
</JSONThreatProtection> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import os | ||
import logging | ||
|
||
EXEC_INFO = True if os.getenv("EXEC_INFO") == "True" else False | ||
LOG_HANDLER = os.getenv("LOG_HANDLER", "Stream") | ||
LOG_FILE_PATH = os.getenv("LOG_FILE_PATH", "app.log") | ||
LOGLEVEL = os.getenv('LOGLEVEL', 'INFO').upper() | ||
|
||
if LOG_HANDLER not in {"File", "Stream"}: | ||
LOG_HANDLER = "Stream" | ||
|
||
if LOGLEVEL not in {"CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "NOTSET"}: | ||
LOGLEVEL = "INFO" | ||
|
||
|
||
class CustomFormatter(logging.Formatter): | ||
|
||
grey = "\x1b[38;20m" | ||
yellow = "\x1b[33;20m" | ||
red = "\x1b[31;20m" | ||
bold_red = "\x1b[31;1m" | ||
reset = "\x1b[0m" | ||
format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)" # noqa | ||
|
||
FORMATS = { | ||
logging.DEBUG: grey + format + reset, | ||
logging.INFO: grey + format + reset, | ||
logging.WARNING: yellow + format + reset, | ||
logging.ERROR: red + format + reset, | ||
logging.CRITICAL: bold_red + format + reset | ||
} | ||
|
||
def format(self, record): | ||
log_fmt = self.FORMATS.get(record.levelno) | ||
formatter = logging.Formatter(log_fmt) | ||
return formatter.format(record) | ||
|
||
|
||
logger = logging.getLogger("TargetServerValidator") | ||
logger.setLevel(getattr(logging, LOGLEVEL)) # Add this line | ||
|
||
if LOG_HANDLER == "File": | ||
ch = logging.FileHandler(LOG_FILE_PATH, mode="a") | ||
else: | ||
ch = logging.StreamHandler() | ||
|
||
ch.setFormatter(CustomFormatter()) | ||
|
||
logger.addHandler(ch) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need an f-string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it.