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:
wing328
2016-07-12 19:51:28 +08:00
committed by GitHub
parent d4951bbf3c
commit 394840e352
146 changed files with 9480 additions and 124 deletions

View File

@@ -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");

View File

@@ -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

View File

@@ -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;
}
/**