code stringlengths 23 2.05k | label_name stringlengths 6 7 | label int64 0 37 |
|---|---|---|
def test_big_arrays(self):
L = (1 << 31) + 100000
tmp = mktemp(suffix='.npz')
a = np.empty(L, dtype=np.uint8)
np.savez(tmp, a=a)
del a
npfile = np.load(tmp)
a = npfile['a']
npfile.close()
os.remove(tmp) | CWE-20 | 0 |
def build_request(self, key_filename, req_config, entry):
"""
creates the certificate request
"""
req = tempfile.mkstemp()[1]
days = self.cert_specs[entry.get('name')]['days']
key = self.data + key_filename
cmd = "openssl req -new -config %s -days %s -key %s -... | CWE-20 | 0 |
public void translate(ServerBlockChangePacket packet, GeyserSession session) {
Position pos = packet.getRecord().getPosition();
boolean updatePlacement = session.getConnector().getPlatformType() != PlatformType.SPIGOT && // Spigot simply listens for the block place event
session.getC... | CWE-287 | 4 |
public void violationMessagesAreEscaped() {
assertThat(ConstraintViolations.format(validator.validate(new InjectionExample()))).containsExactly(
" ${'value'}",
"${'property'} ${'value'}",
"${'property'}[${'key'}] ${'value'}",
"${'property'}[1] ... | CWE-74 | 1 |
public void translate(ServerDeclareTagsPacket packet, GeyserSession session) {
session.getTagCache().loadPacket(packet);
} | CWE-287 | 4 |
static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
unsigned int *rsize)
{
switch (hdev->product) {
case USB_DEVICE_ID_KYE_ERGO_525V:
/* the fixups that need to be done:
* - change led usage page to button for extra buttons
* - report size 8 count 1 must be size 1 count 8 for button
*... | CWE-119 | 26 |
private File createTemporaryFolderIn(File parentFolder) throws IOException {
File createdFolder = null;
for (int i = 0; i < TEMP_DIR_ATTEMPTS; ++i) {
// Use createTempFile to get a suitable folder name.
String suffix = ".tmp";
File tmpFile = File.createTempFile(TM... | CWE-732 | 13 |
default List<MediaType> accept() {
return getAll(HttpHeaders.ACCEPT)
.stream()
.flatMap(x -> Arrays.stream(x.split(",")))
.flatMap(s -> ConversionService.SHARED.convert(s, MediaType.class).map(Stream::of).orElse(Stream.empty()))
.distinct()
.collec... | CWE-400 | 2 |
public int size() {
return ByteUtils.bitLength(k.decode());
} | CWE-345 | 22 |
public void translate(ServerPlayerSetExperiencePacket packet, GeyserSession session) {
SessionPlayerEntity entity = session.getPlayerEntity();
AttributeData experience = GeyserAttributeType.EXPERIENCE.getAttribute(packet.getExperience());
entity.getAttributes().put(GeyserAttributeType.EXPER... | CWE-287 | 4 |
public static Secret decrypt(String data) {
if(data==null) return null;
try {
byte[] in = Base64.decode(data.toCharArray());
Secret s = tryDecrypt(KEY.decrypt(), in);
if (s!=null) return s;
// try our historical key for backward compatibility
... | CWE-326 | 9 |
public void translate(LoginSuccessPacket packet, GeyserSession session) {
PlayerEntity playerEntity = session.getPlayerEntity();
AuthType remoteAuthType = session.getRemoteAuthType();
// Required, or else Floodgate players break with Spigot chunk caching
GameProfile profile = packet... | CWE-287 | 4 |
public OHttpSession removeSession(final String iSessionId) {
acquireExclusiveLock();
try {
return sessions.remove(iSessionId);
} finally {
releaseExclusiveLock();
}
}
| CWE-200 | 10 |
public boolean checkObjectExecutePermission(Class clazz, String methodName)
{
if (Class.class.isAssignableFrom(clazz) && methodName != null && this.secureClassMethods.contains(methodName)) {
return true;
} else {
return super.checkObjectExecutePermission(clazz, methodName... | CWE-668 | 7 |
public ViolationCollector(ConstraintValidatorContext context) {
this.context = context;
} | CWE-74 | 1 |
public void multipleValuesPerNameIteratorWithOtherNames() {
final HttpHeadersBase headers = newEmptyHeaders();
headers.add("name1", "value1");
headers.add("name1", "value2");
headers.add("name2", "value4");
headers.add("name1", "value3");
assertThat(headers.size()).is... | CWE-74 | 1 |
public void translate(LoginDisconnectPacket packet, GeyserSession session) {
// The client doesn't manually get disconnected so we have to do it ourselves
session.disconnect(MessageTranslator.convertMessage(packet.getReason(), session.getLocale()));
} | CWE-287 | 4 |
public void newDocumentFromURLTemplateProviderSpecifiedNonTerminal() throws Exception
{
// new document = xwiki:X.Y
DocumentReference documentReference = new DocumentReference("xwiki", "X", "Y");
XWikiDocument document = mock(XWikiDocument.class);
when(document.getDocumentReferen... | CWE-862 | 8 |
public void translate(EmoteListPacket packet, GeyserSession session) {
if (session.getConnector().getConfig().getEmoteOffhandWorkaround() == EmoteOffhandWorkaroundOption.NO_EMOTES) {
return;
}
session.refreshEmotes(packet.getPieceIds());
} | CWE-287 | 4 |
public void setHeadersShouldOnlyOverwriteHeaders() {
final HttpHeadersBase headers1 = newEmptyHeaders();
headers1.add("name", "value");
headers1.add("name1", "value1");
final HttpHeadersBase headers2 = newEmptyHeaders();
headers2.add("name", "newvalue");
headers2.add... | CWE-74 | 1 |
public void translate(ServerSpawnPositionPacket packet, GeyserSession session) {
SetSpawnPositionPacket spawnPositionPacket = new SetSpawnPositionPacket();
spawnPositionPacket.setBlockPosition(Vector3i.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
... | CWE-287 | 4 |
callback: (request: PublishRequest, response: PublishResponse) => void; | CWE-400 | 2 |
public void canMixConvertedAndNormalValues() {
final HttpHeadersBase headers = newEmptyHeaders();
headers.add("name", "value");
headers.addInt("name", 100);
assertThat(headers.size()).isEqualTo(2);
assertThat(headers.contains("name")).isTrue();
assertThat(headers.con... | CWE-74 | 1 |
public void testUri() {
final HttpHeadersBase headers = newHttp2Headers();
assertThat(headers.uri()).isEqualTo(URI.create("https://netty.io/index.html"));
} | CWE-74 | 1 |
public void translate(ServerSpawnPaintingPacket packet, GeyserSession session) {
Vector3f position = Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ());
PaintingEntity entity = new PaintingEntity(packet.getEntityId(),
session.getEnti... | CWE-287 | 4 |
final void set(CharSequence name, Iterable<String> values) {
final AsciiString normalizedName = normalizeName(name);
requireNonNull(values, "values");
final int h = normalizedName.hashCode();
final int i = index(h);
remove0(h, i, normalizedName);
for (String v : val... | CWE-74 | 1 |
public void translate(PositionTrackingDBClientRequestPacket packet, GeyserSession session) {
PositionTrackingDBServerBroadcastPacket broadcastPacket = new PositionTrackingDBServerBroadcastPacket();
broadcastPacket.setTrackingId(packet.getTrackingId());
// Fetch the stored Loadstone
... | CWE-287 | 4 |
public void existingDocumentFromUITemplateProviderSpecifiedNonTerminalOverridenFromUIToTerminal() throws Exception
{
// current document = xwiki:Main.WebHome
DocumentReference documentReference = new DocumentReference("xwiki", Arrays.asList("Main"), "WebHome");
XWikiDocument document = m... | CWE-862 | 8 |
public void testClearResetsPseudoHeaderDivision() {
final HttpHeadersBase http2Headers = newHttp2Headers();
http2Headers.method(HttpMethod.POST);
http2Headers.set("some", "value");
http2Headers.clear();
http2Headers.method(HttpMethod.GET);
assertThat(http2Headers.name... | CWE-74 | 1 |
private static AsciiString create(String name) {
return AsciiString.cached(Ascii.toLowerCase(name));
} | CWE-74 | 1 |
public void overridingSubClassExample() throws Exception {
assertThat(ConstraintViolations.format(validator.validate(new OverridingExample())))
.isEmpty();
assertThat(TestLoggerFactory.getAllLoggingEvents())
.isEmpty();
} | CWE-74 | 1 |
public void onTurnEnded(TurnEndedEvent event) {
super.onTurnEnded(event);
final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot();
if (out.contains("access denied (java.net.SocketPermission")
|| out.contains("access denied (\"java.net.SocketPermission\"")) {
messagedAccessDen... | CWE-862 | 8 |
public void testOfAsciiString() {
// Should produce a lower-cased AsciiString.
final AsciiString mixedCased = AsciiString.of("Foo");
assertThat((Object) HttpHeaderNames.of(mixedCased)).isNotSameAs(mixedCased);
assertThat(HttpHeaderNames.of(mixedCased).toString()).isEqualTo("foo");
... | CWE-74 | 1 |
public void translate(TextPacket packet, GeyserSession session) {
String message = packet.getMessage();
if (MessageTranslator.isTooLong(message, session)) {
return;
}
ClientChatPacket chatPacket = new ClientChatPacket(message);
session.sendDownstreamPacket(chatP... | CWE-287 | 4 |
public static byte[] computeLength(final byte[] aad) {
final int bitLength = ByteUtils.bitLength(aad);
return ByteBuffer.allocate(8).putLong(bitLength).array();
} | CWE-345 | 22 |
public String render(String templateContent, Map<String, Object> context) {
VelocityContext velocityContext = new VelocityContext(context);
try (StringWriter sw = new StringWriter()) {
Velocity.evaluate(velocityContext, sw, "velocityTemplateEngine", templateContent);
return sw.toString();
}
catch (Except... | CWE-20 | 0 |
public AccessControlList getAccessControlList(String mediaPackageId) throws NotFoundException,
SearchServiceDatabaseException {
EntityManager em = null;
try {
em = emf.createEntityManager();
SearchEntity entity = getSearchEntity(mediaPackageId, em);
if (entity == null) {
throw new ... | CWE-863 | 11 |
public Cipher encrypt() {
try {
Cipher cipher = Secret.getCipher(ALGORITHM);
cipher.init(Cipher.ENCRYPT_MODE, getKey());
return cipher;
} catch (GeneralSecurityException e) {
throw new AssertionError(e);
}
} | CWE-326 | 9 |
private SecretKey getKey() {
try {
if (secret==null) {
synchronized (this) {
if (secret==null) {
byte[] payload = load();
if (payload==null) {
payload = ConfidentialStore.get().randomB... | CWE-326 | 9 |
public void testSetNullHeaderValue() {
final HttpHeadersBase headers = newEmptyHeaders();
headers.set("test", (String) null);
} | CWE-74 | 1 |
void validSaveRequestImageUploadAndConflictCheck() throws Exception
{
when(mockDocument.getRCSVersion()).thenReturn(new Version("1.2"));
when(mockClonedDocument.getRCSVersion()).thenReturn(new Version("1.2"));
when(mockClonedDocument.getComment()).thenReturn("My Changes");
when(m... | CWE-862 | 8 |
final void addObject(CharSequence name, Iterable<?> values) {
final AsciiString normalizedName = normalizeName(name);
requireNonNull(values, "values");
for (Object v : values) {
requireNonNullElement(values, v);
addObject(normalizedName, v);
}
} | CWE-74 | 1 |
function findLateSubscriptionSortedByPriority() {
if (late_subscriptions.length === 0) {
return null;
}
late_subscriptions.sort(compare_subscriptions);
// istanbul ignore next
if (doDebug) {
debugLog(
... | CWE-400 | 2 |
public void translate(ServerAdvancementTabPacket packet, GeyserSession session) {
AdvancementsCache advancementsCache = session.getAdvancementsCache();
advancementsCache.setCurrentAdvancementCategoryId(packet.getTabId());
advancementsCache.buildAndShowListForm();
} | CWE-287 | 4 |
final void add(CharSequence name, String... values) {
final AsciiString normalizedName = normalizeName(name);
requireNonNull(values, "values");
final int h = normalizedName.hashCode();
final int i = index(h);
for (String v : values) {
requireNonNullElement(values,... | CWE-74 | 1 |
public boolean isValid(Object value, ConstraintValidatorContext context) {
final ViolationCollector collector = new ViolationCollector(context);
context.disableDefaultConstraintViolation();
for (ValidationCaller caller : methodMap.computeIfAbsent(value.getClass(), this::findMethods)) {
... | CWE-74 | 1 |
public void translate(ServerCloseWindowPacket packet, GeyserSession session) {
// Sometimes the server can request a window close of ID 0... when the window isn't even open
// Don't confirm in this instance
InventoryUtils.closeInventory(session, packet.getWindowId(), (session.getOpenInventor... | CWE-287 | 4 |
public void translate(ServerEntityPropertiesPacket packet, GeyserSession session) {
Entity entity;
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
entity = session.getPlayerEntity();
} else {
entity = session.getEntityCache().getEntityByJavaId(p... | CWE-287 | 4 |
public void validateFail2(ViolationCollector col) {
col.addViolation(FAILED + "2");
} | CWE-74 | 1 |
protected boolean isProbablePrime(BigInteger x)
{
/*
* Primes class for FIPS 186-4 C.3 primality checking
*/
return !Primes.hasAnySmallFactors(x) && Primes.isMRProbablePrime(x, param.getRandom(), iterations);
} | CWE-327 | 3 |
final void add(CharSequence name, Iterable<String> values) {
final AsciiString normalizedName = normalizeName(name);
requireNonNull(values, "values");
final int h = normalizedName.hashCode();
final int i = index(h);
for (String v : values) {
requireNonNullElement(... | CWE-74 | 1 |
public void translate(RespawnPacket packet, GeyserSession session) {
if (packet.getState() == RespawnPacket.State.CLIENT_READY) {
// Previously we only sent the respawn packet before the server finished loading
// The message included was 'Otherwise when immediate respawn is on the c... | CWE-287 | 4 |
final void add(CharSequence name, String value) {
final AsciiString normalizedName = normalizeName(name);
requireNonNull(value, "value");
final int h = normalizedName.hashCode();
final int i = index(h);
add0(h, i, normalizedName, value);
} | CWE-74 | 1 |
public void translate(MobEquipmentPacket packet, GeyserSession session) {
if (!session.isSpawned() || packet.getHotbarSlot() > 8 ||
packet.getContainerId() != ContainerId.INVENTORY || session.getPlayerInventory().getHeldItemSlot() == packet.getHotbarSlot()) {
// For the last cond... | CWE-287 | 4 |
public void testAddSelf() {
final HttpHeadersBase headers = newEmptyHeaders();
headers.add(headers);
} | CWE-74 | 1 |
private Map<String, Argument<?>> initializeTypeParameters(Argument[] genericTypes) {
Map<String, Argument<?>> typeParameters;
if (genericTypes != null && genericTypes.length > 0) {
typeParameters = new LinkedHashMap<>(genericTypes.length);
for (Argument genericType : genericT... | CWE-400 | 2 |
public void newDocumentWebHomeTopLevelSpaceButTerminalFromURL() throws Exception
{
// new document = xwiki:X.WebHome
DocumentReference documentReference = new DocumentReference("xwiki", Arrays.asList("X"), "WebHome");
XWikiDocument document = mock(XWikiDocument.class);
when(docum... | CWE-862 | 8 |
public File loadOrDownload(String databaseType, String driverFileUrl) {
String filePath = driverFilePath(driverBaseDirectory, databaseType);
Path path = Path.of(filePath);
if (Files.exists(path)) {
// ignore
log.debug("{} already exists, ignore download from {}", file... | CWE-20 | 0 |
public void handle(final HttpServletRequest request, final HttpServletResponse response)
throws Exception
{
new ContextualHttpServletRequest(request)
{
@Override
public void process() throws Exception
{
ServletContexts.instance().setRequest(request);
... | CWE-200 | 10 |
public void translate(ServerEntityMetadataPacket packet, GeyserSession session) {
Entity entity;
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
entity = session.getPlayerEntity();
} else {
entity = session.getEntityCache().getEntityByJavaId(pac... | CWE-287 | 4 |
protected void handleResponse(HttpRequest<?> request, MutableHttpResponse<?> response) {
HttpHeaders headers = request.getHeaders();
Optional<String> originHeader = headers.getOrigin();
originHeader.ifPresent(requestOrigin -> {
Optional<CorsOriginConfiguration> optionalConfig = ... | CWE-400 | 2 |
private void updateStatus() {
if (config.getHIDMode() == 0) {
config.setNetworkStatus(false);
EditorActivity.stopNetworkSocketService(this);
ipButton.setVisibility(View.GONE);
ipStatusDivider.setVisibility(View.GONE);
if (config.getUSBStatus()) {
... | CWE-327 | 3 |
public String render(TemplateEngineTypeEnum engineType, String templateContent, Map<String, Object> context) {
if (StrUtil.isEmpty(templateContent)) {
return StrUtil.EMPTY;
}
TemplateEngine templateEngine = templateEngineMap.get(engineType);
Assert.notNull(templateEngine, "未找到对应的模板引擎:{}", engineType);
ret... | CWE-20 | 0 |
public static synchronized InitialContext getInitialContext() throws NamingException {
if (context == null) {
try {
context = new InitialContext();
} catch (Exception e) {
throw handleException(e);
}
}
return context;
} | CWE-20 | 0 |
public boolean add(MediaPackage sourceMediaPackage, AccessControlList acl, Date now) throws SolrServerException,
UnauthorizedException {
try {
SolrInputDocument episodeDocument = createEpisodeInputDocument(sourceMediaPackage, acl);
Schema.setOcModified(episodeDocument, now);
SolrInput... | CWE-863 | 11 |
public JWECryptoParts encrypt(final JWEHeader header, final byte[] clearText)
throws JOSEException {
JWEAlgorithm alg = header.getAlgorithm();
if (! alg.equals(JWEAlgorithm.DIR)) {
throw new JOSEException(AlgorithmSupportMessage.unsupportedJWEAlgorithm(alg, SUPPORTED_ALGORITHMS));
}
// Check key length... | CWE-345 | 22 |
public void emptyHeaderNameNotAllowed() {
newEmptyHeaders().add("", "foo");
} | CWE-74 | 1 |
public List<Entry> search(final String filter, final Object[] filterArgs, final int maxResultCount) {
return search(filter, filterArgs, resultWrapper -> (Entry) resultWrapper.getResult(), maxResultCount);
} | CWE-74 | 1 |
public void existingDocumentFromUITemplateProviderSpecifiedTerminal() throws Exception
{
// current document = xwiki:Main.WebHome
DocumentReference documentReference = new DocumentReference("xwiki", Arrays.asList("Main"), "WebHome");
XWikiDocument document = mock(XWikiDocument.class);
... | CWE-862 | 8 |
public void newDocumentFromURLWhenNoType() throws Exception
{
// No type has been set by the user
when(mockRequest.get("type")).thenReturn(null);
// new document = xwiki:X.Y
DocumentReference documentReference = new DocumentReference("xwiki", Arrays.asList("X"), "Y");
XW... | CWE-862 | 8 |
public void translate(ServerUpdateViewDistancePacket packet, GeyserSession session) {
session.setRenderDistance(packet.getViewDistance());
} | CWE-287 | 4 |
public void testEqualsInsertionOrderDifferentHeaderNames() {
final HttpHeadersBase h1 = newEmptyHeaders();
h1.add("a", "b");
h1.add("c", "d");
final HttpHeadersBase h2 = newEmptyHeaders();
h2.add("c", "d");
h2.add("a", "b");
assertThat(h1).isEqualTo(h2);
} | CWE-74 | 1 |
public void headersWithSameNamesButDifferentValuesShouldNotBeEquivalent() {
final HttpHeadersBase headers1 = newEmptyHeaders();
headers1.add("name1", "value1");
final HttpHeadersBase headers2 = newEmptyHeaders();
headers1.add("name1", "value2");
assertThat(headers1).isNotEqua... | CWE-74 | 1 |
public boolean isValid(String value, ConstraintValidatorContext context) {
if (StringUtils.isEmpty(value)) {
return true;
}
try {
Pattern.compile(value);
return true;
} catch (Exception ex) {
String errorMessage = String.format("URL parameter '%s' is not a va... | CWE-74 | 1 |
public void testToString() {
HttpHeadersBase headers = newEmptyHeaders();
headers.add("name1", "value1");
headers.add("name1", "value2");
headers.add("name2", "value3");
assertThat(headers.toString()).isEqualTo("[name1=value1, name1=value2, name2=value3]");
headers =... | CWE-74 | 1 |
private SearchResult lookupUser(String accountName) throws NamingException {
InitialDirContext context = initContext();
String searchString = searchFilter.replace(":login", accountName);
SearchControls searchControls = new SearchControls();
String[] attributeFilter = {idAttribute, ... | CWE-74 | 1 |
public void addViolation(String propertyName, String key, String message) {
violationOccurred = true;
String messageTemplate = escapeEl(message);
context.buildConstraintViolationWithTemplate(messageTemplate)
.addPropertyNode(propertyName)
.addBeanNode().inIter... | CWE-74 | 1 |
public void whenNameContainsMultipleValuesGetShouldReturnTheFirst() {
final HttpHeadersBase headers = newEmptyHeaders();
headers.add("name1", "value1", "value2");
assertThat(headers.get("name1")).isEqualTo("value1");
} | CWE-74 | 1 |
static DataSource lookupDataSource(Hints hints) throws FactoryException {
Object hint = hints.get(Hints.EPSG_DATA_SOURCE);
if (hint instanceof DataSource) {
return (DataSource) hint;
} else if (hint instanceof String) {
String name = (String) hint;
Initial... | CWE-20 | 0 |
public void testEqualsInsertionOrderSameHeaderName() {
final HttpHeadersBase h1 = newEmptyHeaders();
h1.add("a", "b");
h1.add("a", "c");
final HttpHeadersBase h2 = newEmptyHeaders();
h2.add("a", "c");
h2.add("a", "b");
assertThat(h1).isNotEqualTo(h2);
} | CWE-74 | 1 |
/*package*/ static SecretKey getLegacyKey() throws GeneralSecurityException {
String secret = SECRET;
if(secret==null) return Jenkins.getInstance().getSecretKeyAsAES128();
return Util.toAes128Key(secret);
} | CWE-326 | 9 |
default boolean isKeepAlive() {
return getFirst(CONNECTION, String.class).map(val -> val.equalsIgnoreCase("keep-alive")).orElse(false);
} | CWE-400 | 2 |
public void existingDocumentFromUITemplateProviderSpecifiedTerminalOverridenFromUIToNonTerminal() throws Exception
{
// current document = xwiki:Main.WebHome
DocumentReference documentReference = new DocumentReference("xwiki", Arrays.asList("Main"), "WebHome");
XWikiDocument document = m... | CWE-862 | 8 |
private ServiceStat getRateLimitOpCountStat() throws Throwable {
URI managementServiceUri = this.host.getManagementServiceUri();
return this.host.getServiceStats(managementServiceUri)
.get(ServiceHostManagementService.STAT_NAME_RATE_LIMITED_OP_COUNT);
} | CWE-732 | 13 |
private List<GHPoint> getPointsFromRequest(HttpServletRequest httpServletRequest, String profile) {
String url = httpServletRequest.getRequestURI();
url = url.replaceFirst("/navigate/directions/v5/gh/" + profile + "/", "");
url = url.replaceAll("\\?[*]", "");
String[] pointStrings ... | CWE-400 | 2 |
public void translate(ServerEntityPositionPacket packet, GeyserSession session) {
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
entity = session.getPlayerEntity();
}
... | CWE-287 | 4 |
public void afterClearHeadersShouldBeEmpty() {
final HttpHeadersBase headers = newEmptyHeaders();
headers.add("name1", "value1");
headers.add("name2", "value2");
assertThat(headers.size()).isEqualTo(2);
headers.clear();
assertThat(headers.size()).isEqualTo(0);
... | CWE-74 | 1 |
public void existingDocumentNonTerminalFromUIDeprecated() throws Exception
{
// current document = xwiki:Main.WebHome
DocumentReference documentReference = new DocumentReference("xwiki", Arrays.asList("Main"), "WebHome");
XWikiDocument document = mock(XWikiDocument.class);
when(d... | CWE-862 | 8 |
public void testAddAndGetUser() throws Exception {
JpaUser user = createUserWithRoles(org1, "user1", "ROLE_ASTRO_101_SPRING_2011_STUDENT");
provider.addUser(user);
User loadUser = provider.loadUser("user1");
assertNotNull(loadUser);
assertEquals(user.getUsername(), loadUser.getUsername());
a... | CWE-327 | 3 |
private void verifyRewrite(File dir) throws Exception {
File xml = new File(dir, "foo.xml");
assertEquals("<foo>" + encryptNew(TEST_KEY) + "</foo>".trim(),
FileUtils.readFileToString(xml).trim());
} | CWE-326 | 9 |
protected OHttpSessionManager() {
expirationTime = OGlobalConfiguration.NETWORK_HTTP_SESSION_EXPIRE_TIMEOUT.getValueAsInteger() * 1000;
Orient.instance().scheduleTask(new TimerTask() {
@Override
public void run() {
final int expired = checkSessionsValidity();
if (exp... | CWE-200 | 10 |
public boolean verify(String token) {
JWTVerifier verifier = JWT.require(Algorithm.HMAC256(SECRET))
.withIssuer(ISSUER)
.build();
try {
verifier.verify(token);
return true;
} catch (JWTVerificationException e) {
log.warn("ve... | CWE-20 | 0 |
private String templatePath() {
if (templatePath == null) {
String file = HgCommand.class.getResource("/hg.template").getFile();
try {
templatePath = URLDecoder.decode(new File(file).getAbsolutePath(), "UTF-8");
} catch (UnsupportedEncodingException e) {
... | CWE-77 | 14 |
public void translate(SetPlayerGameTypePacket packet, GeyserSession session) {
// no
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
playerGameTypePacket.setGamemode(session.getGameMode().ordinal());
session.sendUpstreamPacket(playerGameTypePacket);
... | CWE-287 | 4 |
default Argument<?> getErrorType(MediaType mediaType) {
if (mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) {
return Argument.of(JsonError.class);
} else if (mediaType.equals(MediaType.APPLICATION_VND_ERROR_TYPE)) {
return Argument.of(VndError.class);
} else {
... | CWE-400 | 2 |
public HgVersion version() {
CommandLine hg = createCommandLine("hg").withArgs("version").withEncoding("utf-8");
String hgOut = execute(hg, new NamedProcessTag("hg version check")).outputAsString();
return HgVersion.parse(hgOut);
} | CWE-77 | 14 |
public void translate(ServerPluginMessagePacket packet, GeyserSession session) {
// The only plugin messages it has to listen for are Floodgate plugin messages
if (session.getRemoteAuthType() != AuthType.FLOODGATE) {
return;
}
String channel = packet.getChannel();
... | CWE-287 | 4 |
private boolean isAdmin(String accountName) {
if (this.adminFilter != null) {
try {
InitialDirContext context = initContext();
String searchString = adminFilter.replace(":login", accountName);
SearchControls searchControls = new SearchControls();
... | CWE-74 | 1 |
public void translate(ServerPlayerAbilitiesPacket packet, GeyserSession session) {
session.setCanFly(packet.isCanFly());
session.setFlying(packet.isFlying());
session.sendAdventureSettings();
} | CWE-287 | 4 |
public void existingDocumentFromUITemplateProviderSpecifiedButOldSpaceType() throws Exception
{
// current document = xwiki:Main.WebHome
DocumentReference documentReference = new DocumentReference("xwiki", Arrays.asList("Main"), "WebHome");
XWikiDocument document = mock(XWikiDocument.cla... | CWE-862 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.