#67: Added utf-8 encoding before request

This commit is contained in:
frikky
2020-06-18 20:25:53 +02:00
parent 482b498a98
commit 60b0f783a3
6 changed files with 60 additions and 53 deletions
+3 -1
View File
@@ -5,6 +5,7 @@ import time
import json import json
import logging import logging
import requests import requests
import urllib.parse
class AppBase: class AppBase:
""" The base class for Python-based apps in Shuffle, handles logging and callbacks configurations""" """ The base class for Python-based apps in Shuffle, handles logging and callbacks configurations"""
@@ -536,6 +537,7 @@ class AppBase:
return False, "Failed condition: %s %s %s because %s" % (sourcevalue, condition["condition"]["value"], destinationvalue, check) return False, "Failed condition: %s %s %s because %s" % (sourcevalue, condition["condition"]["value"], destinationvalue, check)
#sourcevalue = sourcevalue.encode("utf-8")
sourcevalue = parse_wrapper_start(sourcevalue) sourcevalue = parse_wrapper_start(sourcevalue)
destinationvalue = condition["destination"]["value"] destinationvalue = condition["destination"]["value"]
@@ -546,6 +548,7 @@ class AppBase:
if check: if check:
return False, "Failed condition: %s %s %s because %s" % (sourcevalue, condition["condition"]["value"], destinationvalue, check) return False, "Failed condition: %s %s %s because %s" % (sourcevalue, condition["condition"]["value"], destinationvalue, check)
#destinationvalue = destinationvalue.encode("utf-8")
destinationvalue = parse_wrapper_start(destinationvalue) destinationvalue = parse_wrapper_start(destinationvalue)
available_checks = [ available_checks = [
"=", "=",
@@ -692,7 +695,6 @@ class AppBase:
# Parses things like int(value) # Parses things like int(value)
self.logger.info("Parsing wrapper data") self.logger.info("Parsing wrapper data")
value = parse_wrapper_start(value) value = parse_wrapper_start(value)
self.logger.info("Parsing done: ", value)
params[parameter["name"]] = value params[parameter["name"]] = value
multi_parameters[parameter["name"]] = value multi_parameters[parameter["name"]] = value
+3 -3
View File
@@ -339,7 +339,7 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet
bodyAddin = ", data=body" bodyAddin = ", data=body"
// FIXME: Does JSON data work? // FIXME: Does JSON data work?
bodyFormatter = `body = " ".join(body.strip().split())` bodyFormatter = `body = " ".join(body.strip().split()).encode("utf-8")`
} }
} }
@@ -499,7 +499,7 @@ func generateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
Description: "The apikey to use", Description: "The apikey to use",
Multiline: false, Multiline: false,
Required: true, Required: true,
Example: "The API key to use. Space = skip", Example: "**********",
Schema: SchemaDefinition{ Schema: SchemaDefinition{
Type: "string", Type: "string",
}, },
@@ -525,7 +525,7 @@ func generateYaml(swagger *openapi3.Swagger, newmd5 string) (*openapi3.Swagger,
Description: "The password to use", Description: "The password to use",
Multiline: false, Multiline: false,
Required: true, Required: true,
Example: "The password to use", Example: "***********",
Schema: SchemaDefinition{ Schema: SchemaDefinition{
Type: "string", Type: "string",
}, },
-2
View File
@@ -31,8 +31,6 @@ services:
- DATASTORE_EMULATOR_HOST=shuffle-database:8000 - DATASTORE_EMULATOR_HOST=shuffle-database:8000
- APP_DOWNLOAD_LOCATION=${APP_DOWNLOAD_LOCATION} - APP_DOWNLOAD_LOCATION=${APP_DOWNLOAD_LOCATION}
- APP_HOTLOAD_FOLDER=/shuffle-apps - APP_HOTLOAD_FOLDER=/shuffle-apps
- https_proxy=http://server:443
- http_proxy=http://server:443
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
- database - database
+39 -40
View File
@@ -2510,7 +2510,7 @@ const AngularWorkflow = (props) => {
<div style={{display: "flex", minHeight: 40, marginBottom: 30}}> <div style={{display: "flex", minHeight: 40, marginBottom: 30}}>
<div style={{flex: 1}}> <div style={{flex: 1}}>
<h3 style={{marginBottom: 5}}>{selectedAction.app_name}</h3> <h3 style={{marginBottom: 5}}>{selectedAction.app_name}</h3>
<Link to="/docs/apps" style={{textDecoration: "none", color: "#f85a3e"}}>What are apps?</Link> <a href="https://shuffler.io/docs/apps#actions" target="_blank" style={{textDecoration: "none", color: "#f85a3e"}}>What are actions?</a>
{selectedAction.errors !== null && selectedAction.errors.length > 0 ? {selectedAction.errors !== null && selectedAction.errors.length > 0 ?
<div> <div>
Errors: {selectedAction.errors.join("\n")} Errors: {selectedAction.errors.join("\n")}
@@ -2544,39 +2544,38 @@ const AngularWorkflow = (props) => {
placeholder={selectedAction.label} placeholder={selectedAction.label}
onChange={selectedNameChange} onChange={selectedNameChange}
/> />
{environments !== undefined && environments.length > 1 ?
<div style={{marginTop: "20px"}}> <div style={{marginTop: "20px"}}>
Environment Environment
<Select <Select
value={selectedActionEnvironment === undefined || selectedActionEnvironment.Name === undefined ? "" : selectedActionEnvironment.Name} value={selectedActionEnvironment === undefined || selectedActionEnvironment.Name === undefined ? "" : selectedActionEnvironment.Name}
PaperProps={{ PaperProps={{
style: { style: {
backgroundColor: inputColor, backgroundColor: inputColor,
} }
}} }}
SelectDisplayProps={{ SelectDisplayProps={{
style: { style: {
marginLeft: 10, marginLeft: 10,
} }
}} }}
fullWidth fullWidth
onChange={(e) => { onChange={(e) => {
const env = environments.find(a => a.Name === e.target.value) const env = environments.find(a => a.Name === e.target.value)
console.log("FOUND: ", e.target.value) setSelectedActionEnvironment(env)
console.log("FOUND2: ", env) selectedAction.environment = env.Name
setSelectedActionEnvironment(env) setSelectedAction(selectedAction)
selectedAction.environment = env.Name }}
setSelectedAction(selectedAction) style={{backgroundColor: inputColor, color: "white", height: "50px"}}
}} >
style={{backgroundColor: inputColor, color: "white", height: "50px"}} {environments.map(data => (
> <MenuItem style={{backgroundColor: inputColor, color: "white"}} value={data.Name}>
{environments.map(data => ( {data.Name}
<MenuItem style={{backgroundColor: inputColor, color: "white"}} value={data.Name}> </MenuItem>
{data.Name} ))}
</MenuItem> </Select>
))} </div>
</Select> : null}
</div>
{/*requiresAuthentication ? {/*requiresAuthentication ?
<div style={{marginTop: "20px"}}> <div style={{marginTop: "20px"}}>
<Button fullWidth style={{margin: "auto", marginTop: "10px",}} color="primary" variant="contained" onClick={() => setAuthenticationModalOpen(true)}> <Button fullWidth style={{margin: "auto", marginTop: "10px",}} color="primary" variant="contained" onClick={() => setAuthenticationModalOpen(true)}>
@@ -3246,7 +3245,7 @@ const AngularWorkflow = (props) => {
<div style={{display: "flex", height: "40px", marginBottom: "30px"}}> <div style={{display: "flex", height: "40px", marginBottom: "30px"}}>
<div style={{flex: "1"}}> <div style={{flex: "1"}}>
<h3 style={{marginBottom: "5px"}} >Branch: Conditions - {selectedEdgeIndex}</h3> <h3 style={{marginBottom: "5px"}} >Branch: Conditions - {selectedEdgeIndex}</h3>
<Link to="/docs/conditions" style={{textDecoration: "none", color: "#f85a3e"}}>What are conditions?</Link> <a href="https://shuffler.io/docs/conditions" style={{textDecoration: "none", color: "#f85a3e"}}>What are conditions?</a>
</div> </div>
</div> </div>
<Divider style={{marginBottom: "10px", marginTop: "10px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/> <Divider style={{marginBottom: "10px", marginTop: "10px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
@@ -3476,7 +3475,7 @@ const AngularWorkflow = (props) => {
<div style={{display: "flex", height: "40px", marginBottom: "30px"}}> <div style={{display: "flex", height: "40px", marginBottom: "30px"}}>
<div style={{flex: "1"}}> <div style={{flex: "1"}}>
<h3 style={{marginBottom: "5px"}}>{selectedTrigger.app_name}: {selectedTrigger.status}</h3> <h3 style={{marginBottom: "5px"}}>{selectedTrigger.app_name}: {selectedTrigger.status}</h3>
<Link to="/docs/triggers#webhook" style={{textDecoration: "none", color: "#f85a3e"}}>What are webhooks?</Link> <a href="https://shuffler.io/docs/triggers#webhook" style={{textDecoration: "none", color: "#f85a3e"}}>What are webhooks?</a>
</div> </div>
</div> </div>
<Divider style={{marginBottom: "10px", marginTop: "10px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/> <Divider style={{marginBottom: "10px", marginTop: "10px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
@@ -3562,7 +3561,7 @@ const AngularWorkflow = (props) => {
<div style={{display: "flex", height: "40px", marginBottom: "30px"}}> <div style={{display: "flex", height: "40px", marginBottom: "30px"}}>
<div style={{flex: "1"}}> <div style={{flex: "1"}}>
<h3 style={{marginBottom: "5px"}}>{selectedTrigger.app_name}: {selectedTrigger.status}</h3> <h3 style={{marginBottom: "5px"}}>{selectedTrigger.app_name}: {selectedTrigger.status}</h3>
<Link to="/docs/triggers#webhook" style={{textDecoration: "none", color: "#f85a3e"}}>What are webhooks?</Link> <a href="https://shuffler.io/docs/triggers#webhook" style={{textDecoration: "none", color: "#f85a3e"}}>What are webhooks?</a>
</div> </div>
</div> </div>
<Divider style={{marginBottom: "10px", marginTop: "10px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/> <Divider style={{marginBottom: "10px", marginTop: "10px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
@@ -3912,7 +3911,7 @@ const AngularWorkflow = (props) => {
<div style={{display: "flex", height: "40px", marginBottom: "30px"}}> <div style={{display: "flex", height: "40px", marginBottom: "30px"}}>
<div style={{flex: "1"}}> <div style={{flex: "1"}}>
<h3 style={{marginBottom: "5px"}}>{selectedTrigger.app_name}: {selectedTrigger.status}</h3> <h3 style={{marginBottom: "5px"}}>{selectedTrigger.app_name}: {selectedTrigger.status}</h3>
<Link to="/docs/triggers#schedule" style={{textDecoration: "none", color: "#f85a3e"}}>What are schedules?</Link> <a href="https://shuffler.io/docs/triggers#schedule" style={{textDecoration: "none", color: "#f85a3e"}}>What are schedules?</a>
</div> </div>
</div> </div>
<Divider style={{marginBottom: "10px", marginTop: "10px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/> <Divider style={{marginBottom: "10px", marginTop: "10px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
@@ -4041,7 +4040,7 @@ const AngularWorkflow = (props) => {
<div style={{display: "flex", height: "40px", marginBottom: "30px"}}> <div style={{display: "flex", height: "40px", marginBottom: "30px"}}>
<div style={{flex: "1"}}> <div style={{flex: "1"}}>
<h3 style={{marginBottom: "5px"}}>{selectedTrigger.app_name}: {selectedTrigger.status}</h3> <h3 style={{marginBottom: "5px"}}>{selectedTrigger.app_name}: {selectedTrigger.status}</h3>
<Link to="/docs/triggers#schedule" style={{textDecoration: "none", color: "#f85a3e"}}>What are schedules?</Link> <a href="https://shuffler.io/docs/triggers#schedule" style={{textDecoration: "none", color: "#f85a3e"}}>What are schedules?</a>
</div> </div>
</div> </div>
<Divider style={{marginBottom: "10px", marginTop: "10px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/> <Divider style={{marginBottom: "10px", marginTop: "10px", height: "1px", width: "100%", backgroundColor: "rgb(91, 96, 100)"}}/>
@@ -4785,7 +4784,7 @@ const AngularWorkflow = (props) => {
> >
<DialogTitle><div style={{color: "white"}}>Authentication for {selectedApp.name}</div></DialogTitle> <DialogTitle><div style={{color: "white"}}>Authentication for {selectedApp.name}</div></DialogTitle>
<DialogContent> <DialogContent>
<Link to="/docs/apps#authentication" style={{textDecoration: "none", color: "#f85a3e"}}>What is this?</Link> <a href="https://shuffler.io/docs/apps#authentication" style={{textDecoration: "none", color: "#f85a3e"}}>What is this?</a>
<div /> <div />
{selectedApp.link.length > 0 ? <EndpointData /> : null} {selectedApp.link.length > 0 ? <EndpointData /> : null}
<div style={{marginTop: 15, marginBottom: 15, }}/> <div style={{marginTop: 15, marginBottom: 15, }}/>
+1 -1
View File
@@ -457,7 +457,7 @@ const Apps = (props) => {
<Paper square style={uploadViewPaperStyle}> <Paper square style={uploadViewPaperStyle}>
<div style={{width: "100%", margin: 25}}> <div style={{width: "100%", margin: 25}}>
<h2>App Creator</h2> <h2>App Creator</h2>
<a href="/docs/apps" style={{textDecoration: "none", color: "#f85a3e"}} target="_blank">How it works</a> <a href="https://shuffler.io/docs/apps" style={{textDecoration: "none", color: "#f85a3e"}} target="_blank">How it works</a>
&nbsp;- <a href="https://github.com/frikky/security-openapis" style={{textDecoration: "none", color: "#f85a3e"}} target="_blank">Security API's</a> &nbsp;- <a href="https://github.com/frikky/security-openapis" style={{textDecoration: "none", color: "#f85a3e"}} target="_blank">Security API's</a>
&nbsp;- <a href="https://apis.guru/browse-apis/" style={{textDecoration: "none", color: "#f85a3e"}} target="_blank">OpenAPI directory</a> &nbsp;- <a href="https://apis.guru/browse-apis/" style={{textDecoration: "none", color: "#f85a3e"}} target="_blank">OpenAPI directory</a>
<div/> <div/>
+14 -6
View File
@@ -614,7 +614,10 @@ const Workflows = (props) => {
showResult = replaceAll(showResult, " None", " \"None\""); showResult = replaceAll(showResult, " None", " \"None\"");
try { try {
JSON.parse(showResult) const tmp = String(JSON.parse(showResult))
if (!tmp.includes("{") && !tmp.includes("[")) {
jsonvalid = false
}
} catch (e) { } catch (e) {
jsonvalid = false jsonvalid = false
} }
@@ -637,7 +640,10 @@ const Workflows = (props) => {
showResult = replaceAll(showResult, " None", " \"None\""); showResult = replaceAll(showResult, " None", " \"None\"");
try { try {
JSON.parse(showResult) const tmp = JSON.parse(showResult)
if (!tmp.includes("{") && !tmp.includes("[")) {
jsonvalid = false
}
} catch (e) { } catch (e) {
jsonvalid = false jsonvalid = false
} }
@@ -657,6 +663,9 @@ const Workflows = (props) => {
<div> <div>
ID: {selectedExecution.execution_id} ID: {selectedExecution.execution_id}
</div> </div>
<div>
<b>Last node:</b> {selectedExecution.workflow.actions.find(data => data.id === selectedExecution.last_node).actions[0].label}
</div>
*/ */
if (Object.getOwnPropertyNames(selectedExecution).length > 0 && selectedExecution.workflow.actions !== null) { if (Object.getOwnPropertyNames(selectedExecution).length > 0 && selectedExecution.workflow.actions !== null) {
return ( return (
@@ -670,12 +679,11 @@ const Workflows = (props) => {
<div> <div>
<b>Finished:</b> {endtime.toISOString()} <b>Finished:</b> {endtime.toISOString()}
</div> </div>
<div> {/*
<b>Last node:</b> {selectedExecution.last_node}
</div>
<div> <div>
<b>Last Result:</b> {lastresult} <b>Last Result:</b> {lastresult}
</div> </div>
*/}
<div style={{marginTop: 10}}> <div style={{marginTop: 10}}>
{arg} {arg}
</div> </div>
@@ -974,7 +982,7 @@ const Workflows = (props) => {
</div> </div>
<div> <div>
<p> <p>
<b>Shuffle</b> is a flexible, easy to use, automation platform allowing users to integrate their services and devices freely. It's made to significantly reduce the amount of manual labor, and is focused on security applications. <Link to="/docs/about" style={{textDecoration: "none", color: "#f85a3e"}}>Click here to learn more.</Link> <b>Shuffle</b> is a flexible, easy to use, automation platform allowing users to integrate their services and devices freely. It's made to significantly reduce the amount of manual labor, and is focused on security applications. <a href="/docs/about" style={{textDecoration: "none", color: "#f85a3e"}}>Click here to learn more.</a>
</p> </p>
</div> </div>
<div> <div>