public ServerTcpPort(JSONObject o) { type = o.getString("type"); value = o.optInt("value"); }
if (url==null || !Util.isSafeToRedirectTo(url)) // avoid open redirect url = req.getContextPath()+'/'+item.getUrl(); rsp.sendRedirect(formData.optInt("statusCode",SC_CREATED), url); } else
public int optInt(String key, int defaultValue) { return jsonObject.optInt(key, defaultValue); }
public int optInt(String key) { return jsonObject.optInt(key); }
/** * Sets all config values from the provided JSONObject. * * @param formData the JSON object with form data. */ public void setValues(JSONObject formData) { numberOfReceivingWorkerThreads = formData.optInt( "numberOfReceivingWorkerThreads", DEFAULT_NR_OF_RECEIVING_WORKER_THREADS); if (numberOfReceivingWorkerThreads <= 0) { numberOfReceivingWorkerThreads = DEFAULT_NR_OF_RECEIVING_WORKER_THREADS; } numberOfSendingWorkerThreads = formData.optInt( "numberOfSendingWorkerThreads", DEFAULT_NR_OF_SENDING_WORKER_THREADS); if (numberOfSendingWorkerThreads <= 0) { numberOfSendingWorkerThreads = DEFAULT_NR_OF_SENDING_WORKER_THREADS; } replicationCacheExpirationInMinutes = formData.optInt("replicationCacheExpirationInMinutes", ReplicationCache.DEFAULT_EXPIRATION_IN_MINUTES); if (replicationCacheExpirationInMinutes <= 0) { replicationCacheExpirationInMinutes = ReplicationCache.DEFAULT_EXPIRATION_IN_MINUTES; } }
public ServerTcpPort(JSONObject o) { type = o.getString("type"); value = o.optInt("value"); }
public int optInt(String arg0, int arg1) { return getJSONObject().optInt(arg0, arg1); } public int optInt(String arg0) {
public int optInt(String arg0) { return getJSONObject().optInt(arg0); } public JSONArray optJSONArray(String arg0) {
/** * 修改信息 * @param mapping * @param form * @param request * @param response * @return * @throws Exception */ @RequestMapping("{id}/editeMsg") public String editeMsg (@PathVariable String id, HttpServletRequest request,HttpServletResponse response) throws Exception{ JSONObject obj = this.messageDao.findMessageById(id); request.setAttribute("message", obj); if( obj.optInt("markdown", -1) == 1 ){ return "editeMsgMD"; } return "editeMsg"; }
@Override public void configure(StaplerRequest req, JSONObject formData) throws IOException, ServletException, Descriptor.FormException { super.configure(req, formData); port = formData.optInt("port", 4444); exclusionPatterns = formData.getString("exclusionPatterns"); hubLogLevel = formData.getString("hubLogLevel"); newSessionWaitTimeout = formData.optInt("newSessionWaitTimeout", -1); maxSession = formData.optInt("maxSession", 5); timeout = formData.optInt("timeout", 300000); browserTimeout = formData.optInt("browserTimeout", 0); throwOnCapabilityNotPresent = formData.getBoolean("throwOnCapabilityNotPresent"); hostnameResolver = req.bindJSON(HostnameResolver.class, formData.optJSONObject("hostnameResolver")); if (hostnameResolver == null) hostnameResolver = new JenkinsRootHostnameResolver(); save(); }
@Override public ApiResponse handleApiAction(String name, JSONObject params) throws ApiException { log.debug("handleApiAction " + name + " " + params.toString()); Context context; switch (name) { case ACTION_SET_AUTHORIZATION_METHOD: context = ApiUtils.getContextByParamId(params, PARAM_CONTEXT_ID); String headerRegex = params.optString(PARAM_HEADER_REGEX, null); String bodyRegex = params.optString(PARAM_BODY_REGEX, null); LogicalOperator logicalOperator = ApiUtils.getOptionalEnumParam(params, PARAM_LOGICAL_OPERATOR, LogicalOperator.class); if (logicalOperator == null) { logicalOperator = LogicalOperator.AND; } int statusCode = params.optInt(PARAM_STATUS_CODE, BasicAuthorizationDetectionMethod.NO_STATUS_CODE); if (log.isDebugEnabled()) { log.debug(String.format("Setting basic authorization detection to: %s / %s / %d / %s", headerRegex, bodyRegex, statusCode, logicalOperator)); } BasicAuthorizationDetectionMethod method = new BasicAuthorizationDetectionMethod(statusCode, headerRegex, bodyRegex, logicalOperator); context.setAuthorizationDetectionMethod(method); return ApiResponseElement.OK; default: throw new ApiException(Type.BAD_ACTION); } }
String result = HttpUtils.postJSON(postUrl, json.toString()); JSONObject jsonObject = JSONObject.fromObject(result); int errcode = jsonObject.optInt("errcode"); if(errcode == 0 && jsonObject.optString("errmsg").equals("ok")){ return true;
private static boolean isTrueCondition(JSONObject stats, JSONObject node, double purityThreshold, int trueIdx) { String nodeIdx = node.optString("id"); JSONArray nodeValues = stats.optJSONObject(nodeIdx).optJSONArray("counts"); double purity = ((double) nodeValues.optInt(trueIdx)) / stats.optJSONObject(nodeIdx).optInt("count"); return purity >= purityThreshold && node.optBoolean("value"); }
private Vulnerability parseVulnerability(JSONObject json) { final String uuid = StringUtils.trimToNull(json.getString("uuid")); final String source = StringUtils.trimToNull(json.getString("source")); final String vulnId = StringUtils.trimToNull(json.optString("vulnId")); final String title = StringUtils.trimToNull(json.optString("title")); final String subtitle = StringUtils.trimToNull(json.optString("subtitle")); final String description = StringUtils.trimToNull(json.optString("description")); final String recommendation = StringUtils.trimToNull(json.optString("recommendation")); final Severity severity = Severity.valueOf(json.optString("severity")); final Integer severityRank = json.optInt("severityRank"); final Integer cweId = json.optInt("cweId"); final String cweName = StringUtils.trimToNull(json.optString("cweName")); return new Vulnerability(uuid, source, vulnId, title, subtitle, description, recommendation, severity, severityRank, cweId, cweName); }
if (url==null || !Util.isSafeToRedirectTo(url)) // avoid open redirect url = req.getContextPath()+'/'+item.getUrl(); rsp.sendRedirect(formData.optInt("statusCode",SC_CREATED), url); } else
private static void processTreeNode(JSONObject node, JSONArray inputs, double purityThreshold, SecondLevelNode currentCondition, List<SecondLevelNode> trueConditions, JSONObject stats, int trueIdx) { if ("thresholdTest".equals(node.optString("type"))) { // conditional node int inputIdx = node.optInt("inputIndex"); HistoDbAttributeId attrId = HistoDbAttributeIdParser.parse(inputs.opt(inputIdx).toString()); double threshold = node.optDouble("threshold"); ComparisonOperator trueCondition = new ComparisonOperator(new Attribute(attrId), new Litteral(threshold), ComparisonOperator.Type.LESS); ComparisonOperator falseCondition = new ComparisonOperator(new Attribute(attrId), new Litteral(threshold), ComparisonOperator.Type.GREATER_EQUAL); processTreeNode(node.optJSONObject("trueChild"), inputs, purityThreshold, currentCondition == null ? trueCondition : new AndOperator(currentCondition.clone(), trueCondition), trueConditions, stats, trueIdx); processTreeNode(node.optJSONObject("falseChild"), inputs, purityThreshold, currentCondition == null ? falseCondition : new AndOperator(currentCondition.clone(), falseCondition), trueConditions, stats, trueIdx); } else { if (currentCondition != null && isTrueCondition(stats, node, purityThreshold, trueIdx)) { trueConditions.add(currentCondition); } } }
public boolean start() { boolean flag = true; try { JSONObject param = new JSONObject(); param.put("url",target); crawlerPage.getRequest().setUrl(API+"/scan/"+taskid+"/start"); crawlerPage.getRequest().addHttpHeader(HttpHeaders.CONTENT_TYPE,"application/json"); crawlerPage.getRequest().setParamStr(param.toString()); crawlerPage.getRequest().setHttpMethod(HttpMethod.POST); fetcher.run(crawlerPage); JSONObject json = crawlerPage.getResponse().getRespFormatJson(); if (json.containsKey("engineid") && json.optBoolean("success")) { engineid = json.optInt("engineid"); status = 2; } }catch (Exception e){ flag = false; } return flag; }