forked from loafle/openapi-generator-original
Add more security samples (#3344)
* add line break test to petstore-security-test.yaml * add objc/swift security testing * add go,scala,qt5cpp for security test * add security test for typescript * fix go security issue, fix consumes,produces line break
This commit is contained in:
@@ -1774,7 +1774,7 @@ public class DefaultCodegen {
|
||||
for (String key : consumes) {
|
||||
Map<String, String> mediaType = new HashMap<String, String>();
|
||||
// escape quotation to avoid code injection
|
||||
mediaType.put("mediaType", escapeQuotationMark(key));
|
||||
mediaType.put("mediaType", escapeText(escapeQuotationMark(key)));
|
||||
count += 1;
|
||||
if (count < consumes.size()) {
|
||||
mediaType.put("hasMore", "true");
|
||||
@@ -1808,7 +1808,7 @@ public class DefaultCodegen {
|
||||
for (String key : produces) {
|
||||
Map<String, String> mediaType = new HashMap<String, String>();
|
||||
// escape quotation to avoid code injection
|
||||
mediaType.put("mediaType", escapeQuotationMark(key));
|
||||
mediaType.put("mediaType", escapeText(escapeQuotationMark(key)));
|
||||
count += 1;
|
||||
if (count < produces.size()) {
|
||||
mediaType.put("hasMore", "true");
|
||||
|
||||
@@ -182,7 +182,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
@Override
|
||||
public String toVarName(String name) {
|
||||
// replace - with _ e.g. created-at => created_at
|
||||
name = name.replaceAll("-", "_");
|
||||
name = sanitizeName(name.replaceAll("-", "_"));
|
||||
|
||||
// if it's all uppper case, do nothing
|
||||
if (name.matches("^[A-Z_]*$"))
|
||||
@@ -346,13 +346,15 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String toOperationId(String operationId) {
|
||||
String sanitizedOperationId = new String(sanitizeName(operationId));
|
||||
|
||||
// method name cannot use reserved keyword, e.g. return
|
||||
if (isReservedWord(operationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId)));
|
||||
operationId = "call_" + operationId;
|
||||
if (isReservedWord(sanitizedOperationId)) {
|
||||
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + camelize("call_" + operationId));
|
||||
sanitizedOperationId = "call_" + sanitizedOperationId;
|
||||
}
|
||||
|
||||
return camelize(operationId);
|
||||
return camelize(sanitizedOperationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,7 @@ public class LumenServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
* @see io.swagger.codegen.CodegenType
|
||||
*/
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user