code
stringlengths
14
2.05k
label
int64
0
1
programming_language
stringclasses
7 values
cwe_id
stringlengths
6
14
cwe_name
stringlengths
5
98
description
stringlengths
36
379
url
stringlengths
36
48
label_name
stringclasses
2 values
public void testFunctionJsonArrayContainsEscapingExpected() throws Exception { filterToSql.setFeatureType(testSchema); Function pointer = ff.function( "jsonArrayContains", ff.property("OPERATIONS"), ff.literal("/operations"), ff.literal("\"'FOO")); filterToSql.encode(pointer); String sql = writer.toString().trim(); assertEquals("OPERATIONS::jsonb @> '{ \"operations\": [\"\\\"''FOO\"] }'::jsonb", sql); }
1
Java
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
public void testFunctionJsonArrayContains() throws Exception { filterToSql.setFeatureType(testSchema); Function pointer = ff.function( "jsonArrayContains", ff.property("OPERATIONS"), ff.literal("/operations"), ff.literal("OP1")); filterToSql.encode(pointer); String sql = writer.toString().trim(); assertEquals("OPERATIONS::jsonb @> '{ \"operations\": [\"OP1\"] }'::jsonb", sql); }
1
Java
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
public void testNestedObjectJsonArrayContains() throws Exception { filterToSql.setFeatureType(testSchema); Function pointer = ff.function( "jsonArrayContains", ff.property("OPERATIONS"), ff.literal("/operations/parameters"), ff.literal("P1")); filterToSql.encode(pointer); String sql = writer.toString().trim(); assertEquals( "OPERATIONS::jsonb @> '{ \"operations\": { \"parameters\": [\"P1\"] } }'::jsonb", sql); }
1
Java
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
public void tearDown() throws Exception { if (this.mocks != null) { this.mocks.close(); this.mocks = null; } if (this.store != null) { this.store.dispose(); } }
1
Java
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
public void testStandardConformingStringsOffWithPSFromConnection() throws Exception { verifyFilterToSqlSettings(true, true, false); }
1
Java
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
public void testStandardConformingStringsOffWithPSFromQuery() throws Exception { verifyFilterToSqlSettings(true, true, true); }
1
Java
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
public void testStandardConformingStringsOnFromConnection() throws Exception { verifyFilterToSqlSettings(false, false, false); }
1
Java
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
public void testStandardConformingStringsOnWithPSFromConnection() throws Exception { verifyFilterToSqlSettings(false, true, false); }
1
Java
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
public void testStandardConformingStringsOnWithPSFromQuery() throws Exception { verifyFilterToSqlSettings(false, true, true); }
1
Java
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
public void testStandardConformingStringsOnFromQuery() throws Exception { verifyFilterToSqlSettings(false, false, true); }
1
Java
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
public void setUp() throws Exception { this.mocks = MockitoAnnotations.openMocks(this); when(this.ds.getConnection()).thenReturn(this.conn); when(this.conn.getMetaData()).thenReturn(this.md); when(this.md.getDatabaseMajorVersion()).thenReturn(15); when(this.md.getDatabaseMinorVersion()).thenReturn(1); when(this.conn.createStatement()).thenReturn(this.st1, this.st2); when(this.st1.executeQuery("select PostGIS_Lib_Version()")).thenReturn(this.rs1); when(this.rs1.next()).thenReturn(true); when(this.rs1.getString(1)).thenReturn("3.3.2"); }
1
Java
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
public void testStandardConformingStringsOffFromQuery() throws Exception { verifyFilterToSqlSettings(true, false, true); }
1
Java
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
private void verifyFilterToSqlSettings( boolean escapeBackslash, boolean withPS, boolean withQuery) throws Exception { if (withQuery) { when(this.st2.executeQuery("SHOW standard_conforming_strings")).thenReturn(this.rs2); when(this.rs2.next()).thenReturn(true); when(this.rs2.getString(1)).thenReturn(escapeBackslash ? "off" : "on"); } else { when(this.conn.isWrapperFor(PgConnection.class)).thenReturn(true); when(this.conn.unwrap(PgConnection.class)).thenReturn(this.pgConn); when(this.pgConn.getStandardConformingStrings()).thenReturn(!escapeBackslash); } Map<String, Object> params = new HashMap<>(); params.put(DATASOURCE.key, this.ds); params.put(PREPARED_STATEMENTS.key, withPS); this.store = new PostgisNGDataStoreFactory().createDataStore(params); assertNotNull(this.store); SQLDialect dialect = this.store.getSQLDialect(); assertThat(dialect, instanceOf(withPS ? PostGISPSDialect.class : PostGISDialect.class)); PostGISDialect pgDialect = withPS ? ((PostGISPSDialect) dialect).getDelegate() : (PostGISDialect) dialect; assertEquals(new Version("15.1"), pgDialect.getPostgreSQLVersion(this.conn)); assertEquals(new Version("3.3.2"), pgDialect.getVersion(this.conn)); assertEquals(escapeBackslash, pgDialect.isEscapeBackslash()); verify(this.conn, withQuery ? times(2) : times(1)).createStatement(); verify(this.conn).close(); verify(this.st1).close(); verify(this.rs1).close(); verify(this.st2, withQuery ? times(1) : never()).close(); verify(this.rs2, withQuery ? times(1) : never()).close(); }
1
Java
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
public void testStandardConformingStringsOffFromConnection() throws Exception { verifyFilterToSqlSettings(true, false, false); }
1
Java
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
public void validate(final OidcCredentials credentials, final WebContext context) { final AuthorizationCode code = credentials.getCode(); // if we have a code if (code != null) { try { final String computedCallbackUrl = client.computeFinalCallbackUrl(context); CodeVerifier verifier = (CodeVerifier) configuration.getValueRetriever() .retrieve(client.getCodeVerifierSessionAttributeName(), client, context).orElse(null); // Token request final TokenRequest request = createTokenRequest(new AuthorizationCodeGrant(code, new URI(computedCallbackUrl), verifier)); HTTPRequest tokenHttpRequest = request.toHTTPRequest(); tokenHttpRequest.setConnectTimeout(configuration.getConnectTimeout()); tokenHttpRequest.setReadTimeout(configuration.getReadTimeout()); final HTTPResponse httpResponse = tokenHttpRequest.send(); logger.debug("Token response: status={}, content={}", httpResponse.getStatusCode(), httpResponse.getContent()); final TokenResponse response = OIDCTokenResponseParser.parse(httpResponse); if (response instanceof TokenErrorResponse) { throw new TechnicalException("Bad token response, error=" + ((TokenErrorResponse) response).getErrorObject()); } logger.debug("Token response successful"); final OIDCTokenResponse tokenSuccessResponse = (OIDCTokenResponse) response; // save tokens in credentials final OIDCTokens oidcTokens = tokenSuccessResponse.getOIDCTokens(); credentials.setAccessToken(oidcTokens.getAccessToken()); credentials.setRefreshToken(oidcTokens.getRefreshToken()); credentials.setIdToken(oidcTokens.getIDToken()); } catch (final URISyntaxException | IOException | ParseException e) { throw new TechnicalException(e); } } }
1
Java
CWE-502
Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
safe
public void configureEurekaUser(AuthenticationManagerBuilder auth) throws Exception { if (!eurekaSecurityEnabled) { return; } InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> configurer = auth .getConfigurer(InMemoryUserDetailsManagerConfigurer.class); if (configurer == null) { configurer = auth.inMemoryAuthentication(); } configurer.withUser(username).password(password).roles(EUREKA_ROLE); }
1
Java
CWE-306
Missing Authentication for Critical Function
The product does not perform any authentication for functionality that requires a provable user identity or consumes a significant amount of resources.
https://cwe.mitre.org/data/definitions/306.html
safe
protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); http.httpBasic(); if (eurekaSecurityEnabled) { http.authorizeRequests() .antMatchers("/eureka/apps/**", "/eureka/instances/**", "/eureka/peerreplication/**") .hasRole(EUREKA_ROLE) .antMatchers("/**").permitAll(); } }
1
Java
CWE-306
Missing Authentication for Critical Function
The product does not perform any authentication for functionality that requires a provable user identity or consumes a significant amount of resources.
https://cwe.mitre.org/data/definitions/306.html
safe
private boolean isImage(MultipartFile file) { BufferedImage image = null; try (InputStream input = file.getInputStream()) { image = ImageIO.read(input); } catch (IOException e) { LogUtil.error(e.getMessage(), e); return false; } Pattern pattern = Pattern.compile("\\.(png|jpg|jpeg|gif)$"); Matcher matcher = pattern.matcher(file.getOriginalFilename().toLowerCase()); if (image == null || image.getWidth() <= 0 || image.getHeight() <= 0 || !matcher.find()) { return false; } return true; }
1
Java
CWE-434
Unrestricted Upload of File with Dangerous Type
The product allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.
https://cwe.mitre.org/data/definitions/434.html
safe
public boolean resetPwd(ResetPwdRequest request, UserDto currentUser) { Optional.ofNullable(currentUser).orElseThrow(() -> new RuntimeException("当前用户为空")); User user = this.getUserById(currentUser.getId()); Optional.ofNullable(user).orElseThrow(() -> new RuntimeException("当前登录用户不存在")); // 非本地创建用户不允许修改密码 if (!"local".equalsIgnoreCase(user.getSource())) { throw new RuntimeException("非云管本地创建的用户无法修改密码"); } if (StringUtils.equals(request.getOldPassword(), request.getNewPassword())) { throw new RuntimeException("新旧密码相同"); } if (!MD5Util.md5(request.getOldPassword()).equalsIgnoreCase(user.getPassword())) { throw new RuntimeException("旧密码错误"); } if (!request.getNewPassword().matches("^(?!.*\\s)(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[\\W_]).{8,30}$")) { throw new RuntimeException("有效密码:8-30位,英文大小写字母+数字+特殊字符"); } user.setPassword(MD5Util.md5(request.getNewPassword())); user.setUpdateTime(null); this.updateById(user); return true; }
1
Java
CWE-521
Weak Password Requirements
The product does not require that users should have strong passwords, which makes it easier for attackers to compromise user accounts.
https://cwe.mitre.org/data/definitions/521.html
safe
default void throwBackupError(String command, int errorCode, Throwable cause) { throw new RuntimeException(String.format("There was an error backing up the database using `%s`. The `%s` process failed with code %s. Please see the server logs for more detail.", command, command, errorCode), cause); }
1
Java
CWE-532
Insertion of Sensitive Information into Log File
Information written to log files can be of a sensitive nature and give valuable guidance to an attacker or expose sensitive user information.
https://cwe.mitre.org/data/definitions/532.html
safe
default void throwBackupError(String command, int errorCode) { throwBackupError(command, errorCode, null); }
1
Java
CWE-532
Insertion of Sensitive Information into Log File
Information written to log files can be of a sensitive nature and give valuable guidance to an attacker or expose sensitive user information.
https://cwe.mitre.org/data/definitions/532.html
safe
public void backup(File targetDir, DataSource dataSource, DbProperties dbProperties) throws InterruptedException, TimeoutException, IOException { try { ProcessResult processResult = createProcessExecutor(targetDir, dbProperties).execute(); if (processResult.getExitValue() == 0) { log.info("MySQL backup finished successfully."); } else { throwBackupError(COMMAND, processResult.getExitValue()); } } catch (ProcessInitException e) { throwBackupError(COMMAND, e.getErrorCode(), e.getCause()); } }
1
Java
CWE-532
Insertion of Sensitive Information into Log File
Information written to log files can be of a sensitive nature and give valuable guidance to an attacker or expose sensitive user information.
https://cwe.mitre.org/data/definitions/532.html
safe
private ProcessExecutor createProcessExecutor(File targetDir, DbProperties dbProperties) { ConnectionUrl connectionUrlInstance = ConnectionUrl.getConnectionUrlInstance(dbProperties.url(), dbProperties.connectionProperties()); Map<String, String> env = new LinkedHashMap<>(); if (isNotBlank(dbProperties.password())) { env.put("MYSQL_PWD", dbProperties.password()); } // override with any user specified environment env.putAll(dbProperties.extraBackupEnv()); List<String> argv = new ArrayList<>(); argv.add(COMMAND); String dbName = connectionUrlInstance.getDatabase(); HostInfo mainHost = connectionUrlInstance.getMainHost(); if (mainHost != null) { argv.add("--host=" + mainHost.getHost()); argv.add("--port=" + mainHost.getPort()); } if (isNotBlank(dbProperties.user())) { argv.add("--user=" + dbProperties.user()); } // append any user specified args for mysqldump if (isNotBlank(dbProperties.extraBackupCommandArgs())) { Collections.addAll(argv, Commandline.translateCommandline(dbProperties.extraBackupCommandArgs())); } argv.add("--result-file=" + new File(targetDir, "db." + dbName)); argv.add(connectionUrlInstance.getDatabase()); ProcessExecutor processExecutor = new ProcessExecutor(); processExecutor.redirectOutputAlsoTo(Slf4jStream.of(getClass()).asDebug()); processExecutor.redirectErrorAlsoTo(Slf4jStream.of(getClass()).asDebug()); processExecutor.environment(env); processExecutor.command(argv); return processExecutor; }
1
Java
CWE-532
Insertion of Sensitive Information into Log File
Information written to log files can be of a sensitive nature and give valuable guidance to an attacker or expose sensitive user information.
https://cwe.mitre.org/data/definitions/532.html
safe
public void backup(File targetDir, DataSource dataSource, DbProperties dbProperties) throws Exception { try { ProcessResult processResult = createProcessExecutor(targetDir, dbProperties).execute(); if (processResult.getExitValue() == 0) { log.info("PostgreSQL backup finished successfully."); } else { throwBackupError(COMMAND, processResult.getExitValue()); } } catch (ProcessInitException e) { throwBackupError(COMMAND, e.getErrorCode(), e.getCause()); } }
1
Java
CWE-532
Insertion of Sensitive Information into Log File
Information written to log files can be of a sensitive nature and give valuable guidance to an attacker or expose sensitive user information.
https://cwe.mitre.org/data/definitions/532.html
safe
ProcessExecutor createProcessExecutor(File targetDir, DbProperties dbProperties) { Properties connectionProperties = dbProperties.connectionProperties(); Properties pgProperties = Driver.parseURL(dbProperties.url(), connectionProperties); Map<String, String> env = new LinkedHashMap<>(); if (isNotBlank(dbProperties.password())) { env.put("PGPASSWORD", dbProperties.password()); } // override with any user specified environment env.putAll(dbProperties.extraBackupEnv()); List<String> argv = new ArrayList<>(); argv.add(COMMAND); String dbName = pgProperties.getProperty("PGDBNAME"); argv.add("--host=" + pgProperties.getProperty("PGHOST")); argv.add("--port=" + pgProperties.getProperty("PGPORT")); argv.add("--dbname=" + dbName); if (isNotBlank(dbProperties.user())) { argv.add("--username=" + dbProperties.user()); } argv.add("--no-password"); // append any user specified args for pg_dump if (isNotBlank(dbProperties.extraBackupCommandArgs())) { Collections.addAll(argv, Commandline.translateCommandline(dbProperties.extraBackupCommandArgs())); } argv.add("--file=" + new File(targetDir, "db." + dbName)); ProcessExecutor processExecutor = new ProcessExecutor(); processExecutor.redirectOutputAlsoTo(Slf4jStream.of(getClass()).asDebug()); processExecutor.redirectErrorAlsoTo(Slf4jStream.of(getClass()).asDebug()); processExecutor.environment(env); processExecutor.command(argv); return processExecutor; }
1
Java
CWE-532
Insertion of Sensitive Information into Log File
Information written to log files can be of a sensitive nature and give valuable guidance to an attacker or expose sensitive user information.
https://cwe.mitre.org/data/definitions/532.html
safe
public void visit(Modification modification) { modifiedFilesJson = new ArrayList<>(); Map<String, Object> jsonMap = new LinkedHashMap<>(); jsonMap.put("user", modification.getUserDisplayName()); jsonMap.put("revision", modification.getRevision()); jsonMap.put("date", formatISO8601(modification.getModifiedTime())); String comment = modification.getComment(); if (!revision.getMaterial().getMaterialType().equals(TYPE)) { comment = commentRenderer.render(comment); } jsonMap.put("comment", comment); jsonMap.put("modifiedFiles", modifiedFilesJson); modificationsJson.add(jsonMap); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void visit(MaterialRevision revision) { this.revision = revision; modificationsJson = new ArrayList<>(); materialJson = new LinkedHashMap<>(); materialJson.put("revision", revision.getRevision().getRevision()); materialJson.put("revision_href", revision.getRevision().getRevisionUrl()); materialJson.put("user", revision.buildCausedBy()); materialJson.put("date", formatISO8601(revision.getDateOfLatestModification())); materialJson.put("changed", valueOf(revision.isChanged())); materialJson.put("modifications", modificationsJson); materials.add(materialJson); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public List<Object> json() { return materials; }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void checkParseErrors() { assertThat(parser.isTrackErrors()).isTrue(); assertThat(parser.getErrors()).isEmpty(); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
private Map<String, Object> createJobDetailModel() { GitMaterialConfig gitMaterialConfig = gitMaterialConfig(); MaterialRevisions materialRevisions = new MaterialRevisions(); materialRevisions.addRevision(new GitMaterial(gitMaterialConfig), new Modification("Ernest Hemingway <[email protected]>", "comment", "email", new Date(), "12", "")); Pipeline pipeline = schedule(pipelineConfig("pipeline", new MaterialConfigs(gitMaterialConfig)), createWithModifications(materialRevisions, "")); JobInstance jobInstance = building("job"); jobInstance.getIdentifier().setPipelineLabel(DODGY_LABEL); JobInstances recent25 = new JobInstances(); recent25.add(jobInstance); JobDetailPresentationModel model = new JobDetailPresentationModel(jobInstance, recent25, null, pipeline, new Tabs(), new TrackingTool(), mock(ArtifactsService.class), StageMother.custom("stage")); return minimalModelFrom(model); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void shouldEscapeRenderedPipelineLabels() { Document actualDoc = parser.parseInput(view.render(createJobDetailModel()), ""); // Header is escaped assertThat(actualDoc.select("#job_details_header").last().html()) .contains(StringEscapeUtils.escapeHtml4(DODGY_LABEL)); // Sidebar links are escaped assertThat(actualDoc.select("#buildlist-container ul li[id=build_list_1]").last().html()) .contains(String.format("pipeline/%s/stage/1/job", StringEscapeUtils.escapeHtml4(DODGY_LABEL))); // Strange JS that updates sidebar should be correctly JS escaped assertThat(actualDoc.select("#build_history_holder script").last().html()) .contains("json_to_css.update_build_list(eval({\"building_info\"") .contains(String.format("\"buildLocatorForDisplay\":\"pipeline/%s/stage/1/job\"", DODGY_LABEL_UNICODE_ESCAPED)); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void shouldEscapeBuildCauseForHtml() { Document actualDoc = parser.parseInput(view.render(createJobDetailModel()), ""); assertThat(actualDoc.select("#build-detail-summary").last().html()) .contains("modified by Ernest Hemingway &lt;[email protected]&gt;"); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void shouldEscapeBuildCauseForJavaScriptViaTrimPathTemplate() { Document actualDoc = parser.parseInput(view.render(createJobDetailModel()), ""); assertThat(actualDoc.select("#build-summary-template").last().html()) .contains("modified by Ernest Hemingway &amp;lt;[email protected]&amp;gt;"); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void setUp() throws Exception { super.setUp("build_detail/build_detail_page.ftlh"); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void shouldRenderArtifactFilesAsRawHtml() { Document actualDoc = parser.parseInput(view.render(createJobDetailModel()), ""); assertThat(actualDoc.select("#tab-content-of-artifacts .files").last().html()) .contains("<a href=\"null\"> console.log </a>"); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void shouldRenderIframeSandboxForTestsTab() { JobDetailPresentationModel jobDetailPresentationModel = mock(JobDetailPresentationModel.class, RETURNS_SMART_NULLS); when(jobDetailPresentationModel.hasTests()).thenReturn(true); when(jobDetailPresentationModel.getCustomizedTabs()).thenReturn(new Tabs()); Document actualDoc = parser.parseInput(view.render(minimalModelFrom(jobDetailPresentationModel)), ""); assertThat(actualDoc.select("#tab-content-of-tests").last().html()) .contains("<iframe sandbox=\"allow-scripts\""); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void shouldHaveErrorMessageAlongWithCustomMessageEscapedCorrectly() { Map<String, Object> data = new HashMap<>(); data.put("errorMessage", "<Error> you shouldn't \"expect\""); String output = view.render(data); assertThat(output).contains("$('trans_content').update(\"Sorry, an unexpected error occurred [<Error> you shouldn\\'t \\\"expect\\\"]. :( Please check the server logs for more information.\");"); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void shouldHaveErrorMessageAlongWithCustomMessageInOutputOfTemplate() { Map<String, Object> data = new HashMap<>(); data.put("errorMessage", "ERROR MESSAGE"); String output = view.render(data); assertThat(output).contains("$('trans_content').update(\"Sorry, an unexpected error occurred [ERROR MESSAGE]. :( Please check the server logs for more information.\");"); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void shouldHaveTheGenericMessageInOutputOfTemplateWhenCustomErrorMessageIsNotProvided() { String output = view.render(new HashMap<>()); assertThat(output).contains("$('trans_content').update(\"Sorry, an unexpected error occurred. :( Please check the server logs for more information.\");"); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public TestFreeMarkerView(String template) throws Exception { FreeMarkerConfigurer configurer = new FreeMarkerConfigurer(); configurer.setDefaultEncoding(StandardCharsets.UTF_8.name()); configurer.setTemplateLoaderPath("file:src/main/webapp/WEB-INF/vm"); Properties settings = new Properties(); settings.put("recognizeStandardFileExtensions", "true"); configurer.setFreemarkerSettings(settings); setConfiguration(configurer.createConfiguration()); setServletContext(new MockServletContext()); setRequestContextAttribute(REQUEST_CONTEXT_ATTRIBUTE); setUrl(template); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void setLogid(String logid) throws PresentationException { synchronized (this) { if ("-".equals(logid)) { this.logid = ""; } else if(StringUtils.isNotBlank(logid) && logid.matches("[\\w-]+")) { this.logid = SolrTools.escapeSpecialCharacters(logid); } else { throw new PresentationException("The passed logId " + SolrTools.escapeSpecialCharacters(logid) + " contains illegal characters"); } } }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void setImageToShow(String imageToShow) { synchronized (lock) { this.imageToShow = imageToShow; if (viewManager != null) { viewManager.setDropdownSelected(String.valueOf(imageToShow)); } // Reset LOGID (the LOGID setter is called later by PrettyFaces, so if a value is passed, it will still be set) try { setLogid(""); } catch (PresentationException e) { //cannot be thrown here } logger.trace("imageToShow: {}", this.imageToShow); } }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void validate(FacesContext context, UIComponent component, String value) throws ValidatorException { if (!validate(value)) { FacesMessage msg = new FacesMessage(ViewerResourceBundle.getTranslation("pi_errInvalid", null), ""); msg.setSeverity(FacesMessage.SEVERITY_ERROR); throw new ValidatorException(msg); } }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public static boolean validate(String name) { if (name == null || name.length() > 10_000) { return false; } Matcher m = PATTERN.matcher(name.toLowerCase()); return m.find(); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void validate_shouldMatchCorrectName() throws Exception { Assert.assertTrue(NameValidator.validate("John Doe")); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void validate_shouldNotMatchInvalidName() throws Exception { Assert.assertTrue(NameValidator.validate("John Doe<script />")); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
protected void copyResponse(InputStream is, OutputStream out, byte[] head, boolean base64) throws IOException { if (base64) { int total = 0; try (BufferedInputStream in = new BufferedInputStream(is, BUFFER_SIZE)) { ByteArrayOutputStream os = new ByteArrayOutputStream(); byte[] buffer = new byte[0xFFFF]; os.write(head, 0, head.length); for (int len = is.read(buffer); len != -1; len = is.read(buffer)) { total += len; if (total > MAX_FETCH_SIZE) { throw new IOException("Size limit exceeded"); } os.write(buffer, 0, len); } out.write(mxBase64.encodeToString(os.toByteArray(), false).getBytes()); } } else { out.write(head); Utils.copyRestricted(is, out, MAX_FETCH_SIZE); } }
1
Java
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
public static void copy(InputStream in, OutputStream out, int bufferSize) throws IOException { copy(in, out, bufferSize, 0); }
1
Java
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
public static int copy(InputStream in, OutputStream out, int bufferSize, int sizeLimit) throws IOException { byte[] b = new byte[bufferSize]; int read, total = 0; while ((read = in.read(b)) != -1) { total += read; if (sizeLimit > 0 && total > sizeLimit) { throw new IOException("Size limit exceeded"); } out.write(b, 0, read); } return total; }
1
Java
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
public static int copyRestricted(InputStream in, OutputStream out, int sizeLimit) throws IOException { return copy(in, out, IO_BUFFER_SIZE, sizeLimit); }
1
Java
CWE-400
Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
private String generateTooltipHtml(CmsListInfoBean infoBean) { Element root = DOM.createElement("div"); appendDom(appendDom(root, "p"), "b").setInnerText(CmsClientStringUtil.shortenString(infoBean.getTitle(), 70)); if (infoBean.hasAdditionalInfo()) { for (CmsAdditionalInfoBean additionalInfo : infoBean.getAdditionalInfo()) { appendDom(root, "p").setInnerText( additionalInfo.getName() + ":\u00a0" + CmsClientStringUtil.shortenString(additionalInfo.getValue(), 45)); } } return root.getInnerHTML(); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
private static Element appendDom(Element parent, String name) { Element child = DOM.createElement(name); parent.appendChild(child); return child; }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public DefaultStompHandler(Vertx vertx) { this.vertx = vertx; this.context = Vertx.currentContext(); this.destinations = vertx.sharedData().getLocalMap("stomp.destinations"); this.users = new ConcurrentHashMap<>(); this.connectHandler = new DefaultConnectHandler(); }
1
Java
CWE-287
Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
safe
public void setUp(TestContext context) { vertx = rule.vertx(); AuthenticationProvider provider = PropertyFileAuthentication.create(vertx, "test-auth.properties"); server = StompServer.create(vertx, new StompServerOptions() .setSecured(true) .setWebsocketBridge(true) .setWebsocketPath("/stomp")) .handler(StompServerHandler.create(vertx).authProvider(provider)); server.listen(StompServerOptions.DEFAULT_STOMP_PORT).onComplete(context.asyncAssertSuccess()); wsServer = vertx.createHttpServer(new HttpServerOptions().setWebSocketSubProtocols(Arrays.asList("v10.stomp", "v11.stomp"))) .webSocketHandler(server.webSocketHandler()); wsServer.listen(8080).onComplete(context.asyncAssertSuccess()); wsClient = vertx.createHttpClient(); client = StompClient.create(vertx, new StompClientOptions().setLogin("admin").setPasscode("admin")); }
1
Java
CWE-287
Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
safe
public void testWebSocketClientMustBeConnected(TestContext context) { Async async = context.async(); testClientMustBeConnected(context, v -> { wsClient.webSocket(8080, "localhost", "/stomp").onComplete(context.asyncAssertSuccess(ws -> { Buffer received = Buffer.buffer(); ws.binaryMessageHandler(received::appendBuffer); ws.writeBinaryMessage( Buffer.buffer("SEND\n" + "destination:/test\n" + "\n" + "hello" + FrameParser.NULL)); ws.endHandler(v2 -> { context.assertTrue(received.toString().startsWith("ERROR\n")); async.complete(); }); })); }); }
1
Java
CWE-287
Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
safe
public void testTCPClientMustBeConnected(TestContext context) { Async async = context.async(); NetClient client = vertx.createNetClient(); testClientMustBeConnected(context, v -> { client.connect(server.actualPort(), "0.0.0.0").onComplete(context.asyncAssertSuccess(so -> { Buffer received = Buffer.buffer(); so.handler(received::appendBuffer); so.write( "SEND\n" + "destination:/test\n" + "\n" + "hello" + FrameParser.NULL); so.endHandler(v2 -> { context.assertTrue(received.toString().startsWith("ERROR\n")); async.complete(); }); })); }); }
1
Java
CWE-287
Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
safe
void validate(TestContext context, Buffer buffer) { context.assertTrue(buffer.toString().contains("CONNECTED"), "Was expected <" + buffer.toString() + "> to contain 'CONNECTED'"); context.assertTrue(buffer.toString().contains("version:1.2")); User user = server.stompHandler().getUserBySession(extractSession(buffer.toString())); context.assertNotNull(user); }
1
Java
CWE-287
Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
safe
private void testClientMustBeConnected(TestContext context, Handler<Void> cont) { client .connect(server.actualPort(), "localhost") .onComplete(context.asyncAssertSuccess(conn -> { Future<String> fut = conn.subscribe("/test", frame -> { context.fail("Should not receive a messsage"); }); fut.onComplete(context.asyncAssertSuccess(v2 -> { cont.handle(null); })); })); }
1
Java
CWE-287
Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
safe
public boolean checkUserPassword(String userId, String password) { if (StringUtils.isBlank(userId)) { MSException.throwException(Translator.get("user_name_is_null")); } if (StringUtils.isBlank(password)) { MSException.throwException(Translator.get("password_is_null")); } if (userId.length() > 64) { MSException.throwException(Translator.get("user_id_length_too_long")); } if (password.length() > 30) { MSException.throwException(Translator.get("password_length_too_long")); } UserExample example = new UserExample(); example.createCriteria().andIdEqualTo(userId).andPasswordEqualTo(CodingUtil.md5(password)); return userMapper.countByExample(example) > 0; }
1
Java
CWE-770
Allocation of Resources Without Limits or Throttling
The product allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.
https://cwe.mitre.org/data/definitions/770.html
safe
public List<User> getCurrentWorkspaceMember() { SessionUser user = SessionUtils.getUser(); Optional<UserGroup> any = user.getUserGroups().stream() .filter(ug -> (ug.getSourceId().equals(SessionUtils.getCurrentWorkspaceId()) || ug.getGroupId().equals(UserGroupConstants.SUPER_GROUP))) .findAny(); if (any.isEmpty()) { return new ArrayList<>(); } QueryMemberRequest request = new QueryMemberRequest(); request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); return baseUserService.getMemberList(request); }
1
Java
CWE-862
Missing Authorization
The product does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
safe
public List<User> getProjectMembers(@PathVariable String projectId) { SessionUser user = SessionUtils.getUser(); Optional<UserGroup> any = user.getUserGroups().stream() .filter(ug -> (ug.getSourceId().equals(projectId) || ug.getGroupId().equals(UserGroupConstants.SUPER_GROUP))) .findAny(); if (any.isEmpty()) { return new ArrayList<>(); } QueryMemberRequest request = new QueryMemberRequest(); request.setProjectId(projectId); return baseUserService.getProjectMemberList(request); }
1
Java
CWE-862
Missing Authorization
The product does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
safe
public List<User> getProjectMemberListAll() { SessionUser user = SessionUtils.getUser(); Optional<UserGroup> any = user.getUserGroups().stream() .filter(ug -> (ug.getSourceId().equals(SessionUtils.getCurrentProjectId()) || ug.getGroupId().equals(UserGroupConstants.SUPER_GROUP))) .findAny(); if (any.isEmpty()) { return new ArrayList<>(); } QueryMemberRequest request = new QueryMemberRequest(); request.setProjectId(SessionUtils.getCurrentProjectId()); return baseUserService.getProjectMemberList(request); }
1
Java
CWE-862
Missing Authorization
The product does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
safe
public List<GroupDTO> getAllGroup() { SessionUser user = SessionUtils.getUser(); Optional<UserGroup> any = user.getUserGroups().stream() .filter(ug -> (ug.getGroupId().equals(UserGroupConstants.SUPER_GROUP))) .findAny(); if (any.isEmpty()) { return new ArrayList<>(); } return groupService.getAllGroup(); }
1
Java
CWE-862
Missing Authorization
The product does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
safe
for (char c = 0; c < FILTER_ESCAPE_TABLE.length; c++) { FILTER_ESCAPE_TABLE[c] = String.valueOf(c); }
1
Java
CWE-295
Improper Certificate Validation
The product does not validate, or incorrectly validates, a certificate.
https://cwe.mitre.org/data/definitions/295.html
safe
private String filterEncode(String value) { if (value == null) { return null; } // make buffer roomy StringBuilder encodedValue = new StringBuilder(value.length() * 2); int length = value.length(); for (int i = 0; i < length; i++) { char c = value.charAt(i); if (c < FILTER_ESCAPE_TABLE.length) { encodedValue.append(FILTER_ESCAPE_TABLE[c]); } else { // default: add the char encodedValue.append(c); } } return encodedValue.toString(); }
1
Java
CWE-295
Improper Certificate Validation
The product does not validate, or incorrectly validates, a certificate.
https://cwe.mitre.org/data/definitions/295.html
safe
public <A extends Output<E>, E extends Exception> void append(A a, char c) throws E { switch (c) { case '"' -> { a.append(QUOT); } case '&' -> { a.append(AMP); } case '\'' -> { a.append(APOS); } case '<' -> { a.append(LT); } case '=' -> { a.append(EQUAL); } case '>' -> { a.append(GT); } case '`' -> { a.append(BACK_TICK); } default -> { a.append(c); } } }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public <A extends Output<E>, E extends Exception> void append(A a, CharSequence csq, int start, int end) throws E { csq = csq == null ? "null" : csq; for (int i = start; i < end; i++) { char c = csq.charAt(i); switch (c) { case '"' -> { // 34 a.append(csq, start, i); start = i + 1; a.append(QUOT); } case '&' -> { // 38 a.append(csq, start, i); start = i + 1; a.append(AMP); } case '\'' -> { // 39 a.append(csq, start, i); start = i + 1; a.append(APOS); } case '<' -> { // 60 a.append(csq, start, i); start = i + 1; a.append(LT); } case '=' -> { // 61 a.append(csq, start, i); start = i + 1; a.append(EQUAL); } case '>' -> { // 62 a.append(csq, start, i); start = i + 1; a.append(GT); } case '`' -> { // 96 a.append(csq, start, i); start = i + 1; a.append(BACK_TICK); } } } a.append(csq, start, end); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public record EscapeModel(String attr, String body) { }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void testName() throws Exception { var m = new EscapeModel("\"&\'<=>`", "\"&\'<=>`"); String actual = EscapeModelRenderer.of().execute(m); String expected = """ <div alt="&quot;&amp;&#x27;&lt;&#x3D;&gt;&#x60;"> &quot;&amp;&#x27;&lt;&#x3D;&gt;&#x60; </div> """; assertEquals(expected, actual); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public void testParent() throws Exception { LambdaSectionParent m = new LambdaSectionParent("ignore"); String actual = JStachio.render(m); String expected = """ bingo LambdaSectionParent[stuff&#x3D;ignore] """; assertEquals(expected, actual); }
1
Java
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
public AFile getAFile(String nameOrPath) throws IOException { final SFile filecurrent; // Log.info("AParentFolderRegular::looking for " + nameOrPath); // Log.info("AParentFolderRegular::dir = " + dir); if (dir == null) filecurrent = new SFile(nameOrPath); else filecurrent = dir.getAbsoluteFile().file(nameOrPath); // Log.info("AParentFolderRegular::Filecurrent " + filecurrent); if (filecurrent.exists()) return new AFileRegular(filecurrent.getCanonicalFile()); return null; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public UGraphic drawAndMove(UGraphic ug, FontConfiguration fontConfiguration, ISkinParam skinParam, double deltax) { final Display display = Display.getWithNewlines(getEmoticon() + getName()); TextBlock result = display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam); result.drawU(ug.apply(UTranslate.dx(deltax))); ug = ug.apply(UTranslate.dy(result.calculateDimension(ug.getStringBounder()).getHeight() + 2)); for (FilesEntry child : children) ug = child.drawAndMove(ug, fontConfiguration, skinParam, deltax + 21); return ug; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
private FilesEntry getOrCreateFolder(String folderName) { for (FilesEntry child : children) if (child.type == FilesType.FOLDER && child.getName().equals(folderName)) return child; final FilesEntry result = new FilesEntry(folderName, FilesType.FOLDER); children.add(result); return result; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public FilesEntry(String name, FilesType type) { this.name = name; this.type = type; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public String getEmoticon() { if (type == FilesType.FOLDER) return "<:1f4c2:>"; // return "<:1f4c1:>"; return "<:1f4c4:>"; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public FilesEntry addRawEntry(String raw) { final int x = raw.indexOf('/'); if (x == -1) { final FilesEntry result = new FilesEntry(raw, FilesType.DATA); children.add(result); return result; } final FilesEntry folder = getOrCreateFolder(raw.substring(0, x)); final String remain = raw.substring(x + 1); if (remain.length() == 0) return folder; return folder.addRawEntry(remain); }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public String getName() { return name; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public Iterator<FilesEntry> iterator() { return Collections.unmodifiableCollection(children).iterator(); }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public void drawU(UGraphic ug) { for (FilesEntry ent : root) ug = ent.drawAndMove(ug, fontConfiguration, skinParam, 0); }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public void add(String line) { if (line.startsWith("/")) root.addRawEntry(line.substring(1)); }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public UImage toUImage(ColorMapper colorMapper, HColor backcolor, HColor forecolor) { final BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); if (backcolor == null) backcolor = HColors.WHITE; if (forecolor == null) forecolor = HColors.BLACK; final HColorGradient gradient = HColors.gradient(backcolor, forecolor, '\0'); for (int col = 0; col < width; col++) { for (int line = 0; line < height; line++) { final int localColor = color[line][col]; if (localColor == -1) { final double coef = 1.0 * gray[line][col] / (16 - 1); final Color c = gradient.getColor(colorMapper, coef, 255); im.setRGB(col, line, c.getRGB()); } else { im.setRGB(col, line, localColor); } } } return new UImage(new PixelImage(im, AffineTransformType.TYPE_BILINEAR)); }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public void setGray(int x, int y, int level) { if (x < 0 || x >= width) return; if (y < 0 || y >= height) return; if (level < 0 || level >= 16) throw new IllegalArgumentException(); gray[y][x] = level; color[y][x] = -1; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public void setColor(int x, int y, int col) { if (x < 0 || x >= width) return; if (y < 0 || y >= height) return; gray[y][x] = -1; color[y][x] = col; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
private void eventuallyConnectAllStandaloneServersToHiddenNetwork() { Network first = null; for (NServer server : servers.values()) if (server.isAlone()) { if (first == null) { first = createNetwork(""); first.goInvisible(); } server.connectMeIfAlone(first); } }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public CommandExecutionResult openNetwork(String name) { if (initDone == false) return errorNoInit(); if (currentGroup() != null) return CommandExecutionResult.error("Cannot open network in a group"); for (NStackable element : stack) if (element instanceof Network) return CommandExecutionResult.error("Cannot nest network"); if (networks.size() == 0 && groups.size() == 0) eventuallyConnectAllStandaloneServersToHiddenNetwork(); final Network network = createNetwork(name); stack.add(0, network); return CommandExecutionResult.ok(); }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public void learnThisAddress(String address) { if (address == null) address = ""; for (Entry<Network, String> ent : connections.entrySet()) { if (ent.getValue().length() == 0) { connections.put(ent.getKey(), address); return; } } }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
private boolean isInUrlAllowList() { final String full = cleanPath(internal.toString()); // Thanks to Agasthya Kasturi if (full.contains("@")) return false; for (String allow : getUrlAllowList()) if (full.startsWith(cleanPath(allow))) return true; return false; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
private boolean forbiddenURL(String full) { // Thanks to Agasthya Kasturi if (full.contains("@")) return true; if (full.startsWith("https://") == false && full.startsWith("http://") == false) return true; if (full.matches("^https?://[-#.0-9:\\[\\]+]+/.*")) return true; if (full.matches("^https?://[^.]+/.*")) return true; if (full.matches("^https?://[^.]+$")) return true; return false; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
private TValue executeReturnLegacyDefine(LineLocation location, TContext context, TMemory memory, List<TValue> args) throws EaterException, EaterExceptionLocated { if (legacyDefinition == null) throw new IllegalStateException(); final TMemory copy = getNewMemory(memory, args, Collections.<String, TValue>emptyMap()); final String tmp = context.applyFunctionsAndVariables(copy, location, legacyDefinition); if (tmp == null) return TValue.fromString(""); return TValue.fromString(tmp); // eaterReturn.execute(context, copy); // // System.err.println("s3=" + eaterReturn.getValue2()); // return eaterReturn.getValue2(); }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public void executeProcedureInternal(TContext context, TMemory memory, List<TValue> args, Map<String, TValue> named) throws EaterException, EaterExceptionLocated { if (functionType != TFunctionType.PROCEDURE && functionType != TFunctionType.LEGACY_DEFINELONG) throw new IllegalStateException(); final TMemory copy = getNewMemory(memory, args, named); context.executeLines(copy, body, TFunctionType.PROCEDURE, false); }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public TFunctionImpl(String functionName, List<TFunctionArgument> args, boolean unquoted, TFunctionType functionType) { final Set<String> names = new HashSet<>(); for (TFunctionArgument tmp : args) names.add(tmp.getName()); this.signature = new TFunctionSignature(functionName, args.size(), names); this.args = args; this.unquoted = unquoted; this.functionType = functionType; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public boolean canCover(int nbArg, Set<String> namedArguments) { for (String n : namedArguments) if (signature.getNamedArguments().contains(n) == false) return false; if (nbArg > args.size()) return false; assert nbArg <= args.size(); int neededArgument = 0; for (TFunctionArgument arg : args) { if (namedArguments.contains(arg.getName())) continue; if (arg.getOptionalDefaultValue() == null) neededArgument++; } if (nbArg < neededArgument) return false; assert nbArg >= neededArgument; return true; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public void addBody(StringLocated s) throws EaterExceptionLocated { body.add(s); if (s.getType() == TLineType.RETURN) { this.containsReturn = true; if (functionType == TFunctionType.PROCEDURE) throw EaterExceptionLocated .located("A procedure cannot have !return directive. Declare it as a function instead ?", s); } }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public void finalizeEnddefinelong() { if (functionType != TFunctionType.LEGACY_DEFINELONG) throw new UnsupportedOperationException(); if (body.size() == 1) { this.functionType = TFunctionType.LEGACY_DEFINE; this.legacyDefinition = body.get(0).getString(); } }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public TValue executeReturnFunction(TContext context, TMemory memory, LineLocation location, List<TValue> args, Map<String, TValue> named) throws EaterException, EaterExceptionLocated { if (functionType == TFunctionType.LEGACY_DEFINE) return executeReturnLegacyDefine(location, context, memory, args); if (functionType != TFunctionType.RETURN_FUNCTION) throw EaterException.unlocated("Illegal call here. Is there a return directive in your function?"); final TMemory copy = getNewMemory(memory, args, named); final TValue result = context.executeLines(copy, body, TFunctionType.RETURN_FUNCTION, true); if (result == null) throw EaterException.unlocated("No return directive found in your function"); return result; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
private TMemory getNewMemory(TMemory memory, List<TValue> values, Map<String, TValue> namedArguments) { final Map<String, TValue> result = new HashMap<String, TValue>(); int ivalue = 0; for (TFunctionArgument arg : args) { final TValue value; if (namedArguments.containsKey(arg.getName())) { value = namedArguments.get(arg.getName()); } else if (ivalue < values.size()) { value = values.get(ivalue); ivalue++; } else { value = arg.getOptionalDefaultValue(); } if (value == null) throw new IllegalStateException(); result.put(arg.getName(), value); } return memory.forkFromGlobal(result); }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public static Collection<SFile> fileCandidates() { final Set<SFile> result = new TreeSet<>(); final String classpath = System.getProperty("java.class.path"); String[] classpathEntries = classpath.split(SFile.pathSeparator); for (String s : classpathEntries) { if (s == null) continue; SFile dir = new SFile(s); if (dir.isFile()) dir = dir.getParentFile(); if (dir != null && dir.isDirectory()) result.add(dir.file("license.txt")); } return result; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public static BufferedImage retrieveDistributorImage(LicenseInfo licenseInfo) { if (licenseInfo.getLicenseType() != LicenseType.DISTRIBUTOR) { return null; } try { final byte[] s1 = PLSSignature.retrieveDistributorImageSignature(); if (SignatureUtils.toHexString(s1).equals(SignatureUtils.toHexString(licenseInfo.sha)) == false) return null; final InputStream dis = PSystemVersion.class.getResourceAsStream("/distributor.png"); if (dis == null) return null; try { final BufferedImage result = SImageIO.read(dis); return result; } finally { dis.close(); } } catch (Exception e) { Logme.error(e); } return null; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
public static synchronized LicenseInfo retrieveNamedSlow() { cache = LicenseInfo.NONE; if (OptionFlags.ALLOW_INCLUDE == false) return cache; final String key = prefs.get("license", ""); if (key.length() > 0) { cache = setIfValid(retrieveNamed(key), cache); if (cache.isValid()) return cache; } for (SFile f : fileCandidates()) { try { if (f.exists() && f.canRead()) { final LicenseInfo result = retrieve(f); if (result == null) return null; cache = setIfValid(result, cache); if (cache.isValid()) return cache; } } catch (IOException e) { Log.info("Error " + e); // Logme.error(e); } } return cache; }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe
private static LicenseInfo retrieve(SFile f) throws IOException { final BufferedReader br = f.openBufferedReader(); if (br == null) return null; try { final String s = br.readLine(); final LicenseInfo result = retrieveNamed(s); if (result != null) Log.info("Reading license from " + f.getAbsolutePath()); return result; } finally { br.close(); } }
1
Java
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
safe