output stringlengths 64 73.2k | input stringlengths 208 73.3k | instruction stringclasses 1
value |
|---|---|---|
#fixed code
public static String getPfadVlc() {
if (Daten.system[Konstanten.SYSTEM_PFAD_VLC_NR].equals("")) {
new DialogOk(null, true, new PanelProgrammPfade(), "Pfade Standardprogramme").setVisible(true);
}
return Daten.system[Konstanten.SYSTEM_PFAD_V... | #vulnerable code
public static String getPfadVlc() {
///////////////////////
if (!Daten.system[Konstanten.SYSTEM_PFAD_VLC_NR].equals("")) {
return Daten.system[Konstanten.SYSTEM_PFAD_VLC_NR];
}
final String PFAD_LINUX_VLC = "/usr/bin/vlc";
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static ListePset getStandardprogramme(DDaten ddaten) {
ListePset pSet;
InputStream datei;
switch (getOs()) {
case OS_LINUX:
datei = new GetFile().getPsetVorlageLinux();
break;
case OS_MAC:
... | #vulnerable code
public static ListePset getStandardprogramme(DDaten ddaten) {
ListePset pSet;
InputStream datei;
if (System.getProperty("os.name").toLowerCase().contains("linux")) {
datei = new GetFile().getPsetVorlageLinux();
} else if (Syst... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static String getMusterPfadVlc() {
final String PFAD_LINUX_VLC = "/usr/bin/vlc";
final String PFAD_MAC_VLC = "/Applications/VLC.app/Contents/MacOS/VLC";
final String PFAD_WIN_DEFAULT = "C:\\Programme\\VideoLAN\\VLC\\vlc.exe";
final Strin... | #vulnerable code
public static String getMusterPfadVlc() {
final String PFAD_LINUX_VLC = "/usr/bin/vlc";
final String PFAD_MAC_VLC = "/Applications/VLC.app/Contents/MacOS/VLC";
String pfad = "";
if (System.getProperty("os.name").toLowerCase().contains("wi... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void stopContainer(String containerId) {
try {
SwarmUtilities.stopServiceByContainerId(containerId);
} catch (DockerException | InterruptedException e) {
logger.warn(nodeId + " Error while stopping the container", e);
... | #vulnerable code
public void stopContainer(String containerId) {
try {
List<Task> tasks = dockerClient.listTasks();
for (Task task : tasks) {
ContainerStatus containerStatus = task.status().containerStatus();
if (containerS... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private String getContainerId(String containerName) {
final String containerNameSearch = containerName.contains("/") ?
containerName : String.format("/%s", containerName);
List<Container> containerList = null;
try {
contain... | #vulnerable code
private String getContainerId(String containerName) {
List<Container> containerList = null;
try {
containerList = dockerClient.listContainers(DockerClient.ListContainersParam.allContainers());
} catch (DockerException | InterruptedExc... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void executeCommand(String containerId, String[] command, boolean waitForExecution) {
String swarmNodeIp = null;
try {
List<Task> tasks = dockerClient.listTasks();
for (Task task : tasks) {
ContainerStatus contain... | #vulnerable code
public void executeCommand(String containerId, String[] command, boolean waitForExecution) {
String swarmNodeIp = null;
try {
List<Task> tasks = dockerClient.listTasks();
for (Task task : tasks) {
if (task.status()... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void pollerThreadTearsDownNodeAfterTestIsCompleted() throws IOException {
// Supported desired capability for the test session
Map<String, Object> requestedCapability = getCapabilitySupportedByDockerSelenium();
// Start poller thread... | #vulnerable code
@Test
public void pollerThreadTearsDownNodeAfterTestIsCompleted() throws IOException {
// Supported desired capability for the test session
Map<String, Object> requestedCapability = getCapabilitySupportedByDockerSelenium();
// Start poller ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String getLatestDownloadedImage(String imageName) {
// TODO: verify this is handled by docker
return imageName;
} | #vulnerable code
public String getLatestDownloadedImage(String imageName) {
List<Image> images;
try {
images = dockerClient.listImages(DockerClient.ListImagesParam.byName(imageName));
if (images.isEmpty()) {
logger.error(nodeId + "... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void stopContainer(String containerId) {
try {
List<Task> tasks = dockerClient.listTasks();
for (Task task : tasks) {
ContainerStatus containerStatus = task.status().containerStatus();
if (containerStatus ... | #vulnerable code
public void stopContainer(String containerId) {
try {
List<Task> tasks = dockerClient.listTasks();
for (Task task : tasks) {
if (task.status().containerStatus().containerId().equals(containerId)) {
Stri... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private String getContainerId(String zaleniumContainerName, URL remoteUrl) {
try {
List<Task> tasks = dockerClient.listTasks();
for (Task task : tasks) {
List<NetworkAttachment> networkAttachments = task.networkAttachments();
... | #vulnerable code
private String getContainerId(String zaleniumContainerName, URL remoteUrl) {
try {
List<Task> tasks = dockerClient.listTasks();
logger.debug("---------------Size of tasks list : {} ---------------", tasks.size());
for (Task ta... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void executeCommand(String containerId, String[] command, boolean waitForExecution) {
try {
Task task = SwarmUtilities.getTaskByContainerId(containerId);
if (task != null) {
pullSwarmExecImage();
startSwar... | #vulnerable code
public void executeCommand(String containerId, String[] command, boolean waitForExecution) {
try {
List<Task> tasks = dockerClient.listTasks();
pullSwarmExecImage();
for (Task task : CollectionUtils.emptyIfNull(tasks)) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@VisibleForTesting
void copyVideos(final String containerId) {
if (testInformation == null || StringUtils.isEmpty(containerId)) {
// No tests run or container has been removed, nothing to copy and nothing to update.
return;
}
... | #vulnerable code
@VisibleForTesting
void copyVideos(final String containerId) {
if (testInformation == null || StringUtils.isEmpty(containerId)) {
// No tests run or container has been removed, nothing to copy and nothing to update.
return;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean isTerminated(ContainerCreationStatus container) {
List<String> termStates = Arrays.asList("complete", "failed", "shutdown", "rejected", "orphaned", "removed");
String containerId = container.getContainerId();
try {
... | #vulnerable code
@Override
public boolean isTerminated(ContainerCreationStatus container) {
List<String> termStates = Arrays.asList("complete", "failed", "shutdown", "rejected", "orphaned", "removed");
String containerId = container.getContainerId();
try {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean isTerminated(ContainerCreationStatus container) {
try {
List<String> termStates = Arrays.asList("complete", "failed", "shutdown", "rejected", "orphaned", "removed");
String containerId = container.getContainerId();
... | #vulnerable code
@Override
public boolean isTerminated(ContainerCreationStatus container) {
List<String> termStates = Arrays.asList("complete", "failed", "shutdown", "rejected", "orphaned", "removed");
String containerId = container.getContainerId();
try {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private ContainerCreationStatus getContainerCreationStatus (String serviceId, String nodePort) throws DockerException, InterruptedException {
List<Task> tasks = dockerClient.listTasks();
for (Task task : tasks) {
if (task.serviceId().equals(service... | #vulnerable code
private ContainerCreationStatus getContainerCreationStatus (String serviceId, String nodePort) throws DockerException, InterruptedException {
List<Task> tasks = dockerClient.listTasks();
for (Task task : tasks) {
if (task.serviceId().equals(s... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@VisibleForTesting
void copyVideos(final String containerId) {
if (testInformation == null || StringUtils.isEmpty(containerId)) {
// No tests run or container has been removed, nothing to copy and nothing to update.
return;
}
... | #vulnerable code
@VisibleForTesting
void copyVideos(final String containerId) {
if (testInformation == null || StringUtils.isEmpty(containerId)) {
// No tests run or container has been removed, nothing to copy and nothing to update.
return;
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public String getContainerIp(String containerName) {
String containerId = this.getContainerId(containerName);
if (containerId == null) {
return null;
}
try {
List<Task> tasks = dockerClient.listTasks();
... | #vulnerable code
@Override
public String getContainerIp(String containerName) {
String containerId = this.getContainerId(containerName);
if (containerId == null) {
return null;
}
try {
ContainerInfo containerInfo = dockerClient... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void loadMountedFolder(String zaleniumContainerName) {
if (this.mountedFolder == null) {
String containerId = getContainerId(String.format("/%s", zaleniumContainerName));
if (containerId == null) {
return;
}
... | #vulnerable code
private void loadMountedFolder(String zaleniumContainerName) {
if (this.mountedFolder == null) {
String containerId = getContainerId(String.format("/%s", zaleniumContainerName));
ContainerInfo containerInfo = null;
try {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
static Future<TermStatus> runAsync(final CommandLine parsed, final List<CommandAtom> commands,
final Function<Commander, Commander> binder) {
/*
* Found command inner run method, double check for CommandAtom
*/
... | #vulnerable code
static Future<TermStatus> runAsync(final CommandLine parsed, final List<CommandAtom> commands,
final Function<Commander, Commander> binder) {
/*
* Found command inner run method
*/
final CommandAto... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
<T> Future<T> fetchOneAsync(final String field, final Object value) {
return JqTool.future(this.vertxDAO.fetchOneAsync(this.analyzer.column(field), value));
} | #vulnerable code
<T> Integer count(final JsonObject filters) {
final DSLContext context = JooqInfix.getDSL();
return null == filters ? context.fetchCount(this.vertxDAO.getTable()) :
context.fetchCount(this.vertxDAO.getTable(), JooqCond.transform(filters, ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private Resolver<T> getResolver(final RoutingContext context,
final Epsilon<T> income) {
/* 1.Read the resolver first **/
final Annotation annotation = income.getAnnotation();
final Class<?> resolverCls = Ut.invoke(a... | #vulnerable code
private Resolver<T> getResolver(final RoutingContext context,
final Epsilon<T> income) {
/* 1.Read the resolver first **/
final Annotation annotation = income.getAnnotation();
final Class<?> resolverCls = Ut.in... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
<T> Future<T> fetchOneAsync(final String field, final Object value) {
return JqTool.future(this.vertxDAO.fetchOneAsync(this.analyzer.column(field), value));
} | #vulnerable code
<T> Integer count(final JsonObject filters) {
final DSLContext context = JooqInfix.getDSL();
return null == filters ? context.fetchCount(this.vertxDAO.getTable()) :
context.fetchCount(this.vertxDAO.getTable(), JooqCond.transform(filters, ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public String unique(final CacheMeta meta) {
final TreeMap<String, String> treeMap = new TreeMap<>();
treeMap.put(meta.primaryString(), this.id);
return CacheTool.keyId(meta.typeName(), treeMap);
} | #vulnerable code
@Override
public String unique(final CacheMeta meta) {
final Class<?> entityCls = meta.type();
final TreeMap<String, String> treeMap = new TreeMap<>();
treeMap.put(meta.primaryString(), this.id);
return CacheTool.keyId(entityCls.getNa... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void onTable(final Cell cell) {
final DyeCell dyeCell = Fn.pool(this.stylePool, "TABLE",
() -> DyeCell.create(this.workbook)
.color("FFFFFF", "3EB7FF")
.align(HorizontalAlignment.CENTER)
... | #vulnerable code
void onData(final Cell cell) {
final DyeCell dye;
if (CellType.NUMERIC == cell.getCellType()) {
/*
* Buf for date exporting here
*/
final double cellValue = cell.getNumericCellValue();
if (Dat... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
<T> Future<JsonObject> searchAsync(final JsonObject params, final JqFlow workflow) {
return this.search.searchAsync(params, workflow);
} | #vulnerable code
<T> T fetchOne(final JsonObject filters) {
final Condition condition = JooqCond.transform(filters, Operator.AND, this.analyzer::column);
final DSLContext context = JooqInfix.getDSL();
return this.toResult(context.selectFrom(this.vertxDAO.getTable... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Future<JsonArray> groupAsync(final String sigma) {
/*
* Build condition of `sigma`
*/
final JsonObject condition = new JsonObject();
condition.put(KeField.SIGMA, sigma);
/*
* Permission Groups pro... | #vulnerable code
@Override
public Future<JsonArray> groupAsync(final String sigma) {
/*
* Build condition of `sigma`
*/
final JsonObject condition = new JsonObject();
condition.put(KeField.SIGMA, sigma);
/*
* Permission Grou... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Address(Addr.Authority.PERMISSION_BY_ROLE)
public Future<JsonArray> fetchAsync(final String roleId) {
return Fn.getEmpty(Ux.futureJArray(), () -> Ux.Jooq.on(RRolePermDao.class)
.fetchAsync(KeField.ROLE_ID, roleId)
.compose(Ux::fnJA... | #vulnerable code
@Address(Addr.Authority.PERMISSION_BY_ROLE)
public Future<JsonArray> fetchAsync(final String roleId) {
if (Ut.notNil(roleId)) {
return Ux.Jooq.on(RRolePermDao.class)
.fetchAsync(KeField.ROLE_ID, roleId)
.co... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
L1Cache cacheL1() {
L1Cache cache = null;
final Class<?> componentCls = this.l1Config.getComponent();
if (Objects.nonNull(componentCls) && Ut.isImplement(componentCls, L1Cache.class)) {
/*
* L1 cache here
*/
... | #vulnerable code
L1Cache cacheL1() {
L1Cache cache = null;
final Class<?> componentCls = this.l1Config.getComponent();
if (Objects.nonNull(componentCls) && Ut.isImplement(componentCls, L1Cache.class)) {
/*
* L1 cache here
*/
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Future<JsonArray> syncPerm(final JsonArray permissions, final String group, final String sigma) {
/*
* 1. permissions ->
* -- ADD = List
* -- UPDATE = List
* -- DELETE = List
*/
final Set<String... | #vulnerable code
@Override
public Future<JsonArray> syncPerm(final JsonArray permissions, final String group, final String sigma) {
/*
* Fetch all permissions from database and calculated removed list
*/
final JsonObject condition = new JsonObject()... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Future<JsonObject> fetchModule(final String appId, final String entry) {
final JsonObject filters = new JsonObject()
.put("", Boolean.TRUE)
.put("entry", entry)
.put("appId", appId);
/*
... | #vulnerable code
@Override
public Future<JsonObject> fetchModule(final String appId, final String entry) {
final JsonObject filters = new JsonObject()
.put("", Boolean.TRUE)
.put("entry", entry)
.put("appId", appId);
re... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void mount(final Router router) {
final Class<?> clazz = ZeroAmbient.getPlugin(PlugRouter.KEY_ROUTER);
if (Values.ZERO == LOG_FLAG_START.getAndIncrement()) {
LOGGER.info(Info.DY_DETECT, NAME);
}
if (null != claz... | #vulnerable code
@Override
public void mount(final Router router) {
final Class<?> clazz = ZeroAmbient.getPlugin(KEY_ROUTER);
if (Values.ZERO == LOG_FLAG_START.getAndIncrement()) {
LOGGER.info(Info.DY_DETECT, NAME);
}
if (null != clazz && ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void onTable(final Cell cell) {
final DyeCell dyeCell = Fn.pool(this.stylePool, "TABLE",
() -> DyeCell.create(this.workbook)
.color("FFFFFF", "3EB7FF")
.align(HorizontalAlignment.CENTER)
... | #vulnerable code
void onData(final Cell cell) {
final DyeCell dyeCell = Fn.pool(this.stylePool, "DATA",
() -> DyeCell.create(this.workbook)
.border(BorderStyle.THIN)
.align(null, VerticalAlignment.TOP)
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
static Object invokeSingle(final Object proxy,
final Method method,
final Envelop envelop) {
final Class<?> argType = method.getParameterTypes()[Values.IDX];
// Append single argument
final ... | #vulnerable code
static Object invokeSingle(final Object proxy,
final Method method,
final Envelop envelop) {
final Class<?> argType = method.getParameterTypes()[Values.IDX];
// One type dynamic here
f... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
void onTable(final Cell cell) {
final DyeCell dyeCell = Fn.pool(this.stylePool, "TABLE",
() -> DyeCell.create(this.workbook)
.color("FFFFFF", "3EB7FF")
.align(HorizontalAlignment.CENTER)
... | #vulnerable code
void onData(final Cell cell) {
final DyeCell dye;
if (CellType.NUMERIC == cell.getCellType()) {
/*
* Buf for date exporting here
*/
final double cellValue = cell.getNumericCellValue();
if (Dat... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void mountSession(final Router router) {
if (ZeroHeart.isSession()) {
/*
* Session Global for Authorization, replace old mode with
* SessionClient, this client will get SessionStore
* by configuration informat... | #vulnerable code
private void mountSession(final Router router) {
if (ZeroHeart.isSession()) {
/*
* Session Global for Authorization, replace old mode with
* SessionClient, this client will get SessionStore
* by configuration in... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void register(JsonProvider jsonProvider) {
this.registeredJsonProvider = Objects.requireNonNull(jsonProvider);
} | #vulnerable code
public void register(JsonProvider jsonProvider) {
this.registeredJsonProvider = Objects.requireNonNull(jsonProvider);
logger.debug(() -> "Set json provider to " + jsonProvider.getClass().getName());
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testParse_Map1() {
BEParser parser = new BEParser("d4:spaml1:a1:bee".getBytes());
assertEquals(BEType.MAP, parser.readType());
byte[][] expected = new byte[][] {"a".getBytes(charset), "b".getBytes(charset)};
Map<String, ... | #vulnerable code
@Test
public void testParse_Map1() {
BEParser parser = new BEParser("d4:spaml1:a1:bee");
assertEquals(BEType.MAP, parser.readType());
Map<String, Object> expected = new HashMap<>();
expected.put("spam", Arrays.asList("a", "b"));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_ZeroLength() {
BEParser parser = new BEParser("ie".getBytes());
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
} | #vulnerable code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_ZeroLength() {
BEParser parser = new BEParser("ie");
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
}
#location... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testParse_String2() {
BEParser parser = new BEParser("11:!@#$%^&*()_".getBytes());
assertEquals(BEType.STRING, parser.readType());
assertEquals("!@#$%^&*()_", parser.readString(charset));
} | #vulnerable code
@Test
public void testParse_String2() {
BEParser parser = new BEParser("11:!@#$%^&*()_");
assertEquals(BEType.STRING, parser.readType());
assertEquals("!@#$%^&*()_", parser.readString());
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(expected = Exception.class)
public void testParse_String_Exception_EmptyString() {
new BEParser("".getBytes());
} | #vulnerable code
@Test(expected = Exception.class)
public void testParse_String_Exception_EmptyString() {
new BEParser("");
}
#location 3
#vulnerability type RESOURCE_LEAK | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testParse_String1() {
BEParser parser = new BEParser("1:s".getBytes());
assertEquals(BEType.STRING, parser.readType());
assertEquals("s", parser.readString(charset));
} | #vulnerable code
@Test
public void testParse_String1() {
BEParser parser = new BEParser("1:s");
assertEquals(BEType.STRING, parser.readType());
assertEquals("s", parser.readString());
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testParse_Integer_Negative() {
BEParser parser = new BEParser("i-1e".getBytes());
assertEquals(BEType.INTEGER, parser.readType());
assertEquals(BigInteger.ONE.negate(), parser.readInteger());
} | #vulnerable code
@Test
public void testParse_Integer_Negative() {
BEParser parser = new BEParser("i-1e");
assertEquals(BEType.INTEGER, parser.readType());
assertEquals(BigInteger.ONE.negate(), parser.readInteger());
}
#locatio... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testParse_String2() {
BEParser parser = new BEParser("11:!@#$%^&*()_".getBytes());
assertEquals(BEType.STRING, parser.readType());
assertEquals("!@#$%^&*()_", parser.readString(charset));
} | #vulnerable code
@Test
public void testParse_String2() {
BEParser parser = new BEParser("11:!@#$%^&*()_");
assertEquals(BEType.STRING, parser.readType());
assertEquals("!@#$%^&*()_", parser.readString());
}
#location 5
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testParse_Integer_Negative() {
BEParser parser = new BEParser("i-1e".getBytes());
assertEquals(BEType.INTEGER, parser.readType());
assertEquals(BigInteger.ONE.negate(), parser.readInteger());
} | #vulnerable code
@Test
public void testParse_Integer_Negative() {
BEParser parser = new BEParser("i-1e");
assertEquals(BEType.INTEGER, parser.readType());
assertEquals(BigInteger.ONE.negate(), parser.readInteger());
}
#locatio... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_UnexpectedTokens() {
BEParser parser = new BEParser("i-1-e".getBytes());
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
} | #vulnerable code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_UnexpectedTokens() {
BEParser parser = new BEParser("i-1-e");
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_ZeroLength() {
BEParser parser = new BEParser("ie".getBytes());
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
} | #vulnerable code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_ZeroLength() {
BEParser parser = new BEParser("ie");
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
}
#location... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testDescriptors_WriteMultiFile() {
String torrentName = "xyz-torrent";
File torrentDirectory = new File(rootDirectory, torrentName);
String extension = "-multi.bin";
String fileName1 = 1 + extension,
fileN... | #vulnerable code
@Test
public void testDescriptors_WriteMultiFile() {
String torrentName = "xyz-torrent";
File torrentDirectory = new File(rootDirectory, torrentName);
String extension = "-multi.bin";
String fileName1 = 1 + extension,
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testParse_Map1() {
BEParser parser = new BEParser("d4:spaml1:a1:bee".getBytes());
assertEquals(BEType.MAP, parser.readType());
byte[][] expected = new byte[][] {"a".getBytes(charset), "b".getBytes(charset)};
Map<String, ... | #vulnerable code
@Test
public void testParse_Map1() {
BEParser parser = new BEParser("d4:spaml1:a1:bee");
assertEquals(BEType.MAP, parser.readType());
Map<String, Object> expected = new HashMap<>();
expected.put("spam", Arrays.asList("a", "b"));
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_NotTerminated() {
BEParser parser = new BEParser("i1".getBytes());
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
} | #vulnerable code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_NotTerminated() {
BEParser parser = new BEParser("i1");
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
}
#locat... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected void doExecute(MagnetContext context) {
TorrentId torrentId = context.getMagnetUri().getTorrentId();
MetadataConsumer metadataConsumer = new MetadataConsumer(metadataService, torrentId, config);
context.getRouter().registerMess... | #vulnerable code
@Override
protected void doExecute(MagnetContext context) {
TorrentId torrentId = context.getMagnetUri().getTorrentId();
MetadataFetcher metadataFetcher = new MetadataFetcher(metadataService, torrentId);
context.getRouter().registerMessaging... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testParse_List1() {
BEParser parser = new BEParser("l4:spam4:eggsi1ee".getBytes());
assertEquals(BEType.LIST, parser.readType());
assertArrayEquals(
new Object[] {"spam".getBytes(charset), "eggs".getBytes(charset),... | #vulnerable code
@Test
public void testParse_List1() {
BEParser parser = new BEParser("l4:spam4:eggsi1ee");
assertEquals(BEType.LIST, parser.readType());
assertArrayEquals(
new Object[] {"spam", "eggs", BigInteger.ONE},
parser.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test//(expected = Exception.class)
public void testParse_Integer_Exception_NegativeZero() {
// not sure why the protocol spec forbids negative zeroes,
// so let it be for now
BEParser parser = new BEParser("i-0e".getBytes());
assertEquals(... | #vulnerable code
@Test//(expected = Exception.class)
public void testParse_Integer_Exception_NegativeZero() {
// not sure why the protocol spec forbids negative zeroes,
// so let it be for now
BEParser parser = new BEParser("i-0e");
assertEquals(BETyp... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_NotTerminated() {
BEParser parser = new BEParser("i1".getBytes());
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
} | #vulnerable code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_NotTerminated() {
BEParser parser = new BEParser("i1");
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
}
#locat... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testParse_Integer1() {
BEParser parser = new BEParser("i1e".getBytes());
assertEquals(BEType.INTEGER, parser.readType());
assertEquals(BigInteger.ONE, parser.readInteger());
} | #vulnerable code
@Test
public void testParse_Integer1() {
BEParser parser = new BEParser("i1e");
assertEquals(BEType.INTEGER, parser.readType());
assertEquals(BigInteger.ONE, parser.readInteger());
}
#location 5
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testConnection() throws InvalidMessageException, IOException {
IPeerConnection connection = new PeerConnection(mock(Peer.class), clientChannel);
Message message;
server.writeMessage(new Handshake(new byte[20], new byte[20]));
... | #vulnerable code
@Test
public void testConnection() throws InvalidMessageException, IOException {
PeerConnection connection = new PeerConnection(mock(Peer.class), clientChannel);
Message message;
server.writeMessage(new Handshake(new byte[20], new byte[20])... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(expected = Exception.class)
public void testParse_String_Exception_LengthStartsWithZero() {
new BEParser("0:".getBytes()).readString(charset);
} | #vulnerable code
@Test(expected = Exception.class)
public void testParse_String_Exception_LengthStartsWithZero() {
new BEParser("0:").readString();
}
#location 3
#vulnerability type RESOURCE_LEAK | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test//(expected = Exception.class)
public void testParse_Integer_Exception_NegativeZero() {
// not sure why the protocol spec forbids negative zeroes,
// so let it be for now
BEParser parser = new BEParser("i-0e".getBytes());
assertEquals(... | #vulnerable code
@Test//(expected = Exception.class)
public void testParse_Integer_Exception_NegativeZero() {
// not sure why the protocol spec forbids negative zeroes,
// so let it be for now
BEParser parser = new BEParser("i-0e");
assertEquals(BETyp... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testParse_Integer1() {
BEParser parser = new BEParser("i1e".getBytes());
assertEquals(BEType.INTEGER, parser.readType());
assertEquals(BigInteger.ONE, parser.readInteger());
} | #vulnerable code
@Test
public void testParse_Integer1() {
BEParser parser = new BEParser("i1e");
assertEquals(BEType.INTEGER, parser.readType());
assertEquals(BigInteger.ONE, parser.readInteger());
}
#location 3
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_UnexpectedTokens() {
BEParser parser = new BEParser("i-1-e".getBytes());
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
} | #vulnerable code
@Test(expected = Exception.class)
public void testParse_Integer_Exception_UnexpectedTokens() {
BEParser parser = new BEParser("i-1-e");
assertEquals(BEType.INTEGER, parser.readType());
parser.readInteger();
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testDescriptors_WriteSingleFile() {
String fileName = "1-single.bin";
IDataDescriptor descriptor = createDataDescriptor_SingleFile(fileName);
List<IChunkDescriptor> chunks = descriptor.getChunkDescriptors();
chunks.get(0... | #vulnerable code
@Test
public void testDescriptors_WriteSingleFile() {
String fileName = "1-single.bin";
long chunkSize = 16;
long fileSize = chunkSize * 4;
Torrent torrent = mockTorrent(fileName, fileSize, chunkSize,
new byte[][] {... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testParse_String1() {
BEParser parser = new BEParser("1:s".getBytes());
assertEquals(BEType.STRING, parser.readType());
assertEquals("s", parser.readString(charset));
} | #vulnerable code
@Test
public void testParse_String1() {
BEParser parser = new BEParser("1:s");
assertEquals(BEType.STRING, parser.readType());
assertEquals("s", parser.readString());
}
#location 5
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void delete(String key) throws IOException {
delete(propertyFile, key);
} | #vulnerable code
public static void delete(String key) throws IOException {
Properties props = getProperty();
OutputStream fos = new FileOutputStream(propertyFile);
props.remove(key);
props.store(fos, "Delete '" + key + "' value");
}
#location 6
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void serverTreeItemSelected(TreeItem selectedItem, boolean refresh) {
this.itemSelected = selectedItem;
tree.setSelection(selectedItem);
text.setText(selectedItem.getText() + ":");
table.removeAll();
serverItemSelected();
int amount = service1.listDBs((Inte... | #vulnerable code
private void serverTreeItemSelected(TreeItem selectedItem, boolean refresh) {
this.itemSelected = selectedItem;
tree.setSelection(selectedItem);
text.setText(selectedItem.getText() + ":");
table.removeAll();
serverItemSelected();
if (refresh)
selectedItem.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void execute() {
try {
server = service.listById(id);
jedis = new Jedis(server.getHost(), Integer.parseInt(server.getPort()));
command();
jedis.close();
} catch (IOException e) {
e.printStackTrace();
}
} | #vulnerable code
public void execute() {
try {
server = service.listById(id);
jedis = new Jedis(server.getHost(), Integer.parseInt(server
.getPort()));
if (commands.size() > 0) {
RedisVersion version;
if (serverVersion.containsKey(String.valueOf(id))) {
version... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void pasteContainer(int sourceId, int sourceDb, String sourceContainer, int targetId, int targetDb, String targetContainer, boolean copy, boolean overwritten) {
Set<Node> nodes = listContainerAllKeys(sourceId, sourceDb, sourceContainer);
for(Node node: nodes) {
... | #vulnerable code
public void pasteContainer(int sourceId, int sourceDb, String sourceContainer, int targetId, int targetDb, String targetContainer, boolean copy, boolean overwritten) {
ListContainerAllKeys command = new ListContainerAllKeysFactory(sourceId, sourceDb, sourceContainer).get... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void write(String key, String value) throws IOException {
write(propertyFile, key, value);
} | #vulnerable code
public static void write(String key, String value) throws IOException {
Properties props = getProperty();
OutputStream fos = new FileOutputStream(propertyFile);
props.setProperty(key, value);
props.store(fos, "Update '" + key + "' value");
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public boolean execute(DiagnosticContext context) {
if (context.getInputParams().isSkipLogs() || ! context.isProcessLocal()) {
return true;
}
JsonNode diagNode = context.getTypedAttribute("diagNode", JsonNode.class);
if(diagNode == null){
... | #vulnerable code
public boolean execute(DiagnosticContext context) {
if (context.getInputParams().isSkipLogs()) {
return true;
}
JsonNode diagNode = context.getTypedAttribute("diagNode", JsonNode.class);
boolean getAccess = context.getInputParams().isAc... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void zipResults(String dir) {
try {
File srcDir = new File(dir);
FileOutputStream fout = new FileOutputStream(dir + ".tar.gz");
GZIPOutputStream gzout = new GZIPOutputStream(fout);
TarArchiveOutputStream taos = n... | #vulnerable code
public void zipResults(String dir) {
try {
File srcDir = new File(dir);
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(dir + ".zip"));
out.setLevel(ZipOutputStream.DEFLATED);
SystemUtils.zipDir("",... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void createArchive(String dir, String archiveFileName) {
if(! createZipArchive(dir, archiveFileName)){
logger.info("Couldn't create zip archive. Trying tar.gz");
if(! createTarArchive(dir, archiveFileName)){
logger.info("Couldn't crea... | #vulnerable code
public void createArchive(String dir, String archiveFileName) {
try {
File srcDir = new File(dir);
String filename = dir + "-" + archiveFileName + ".tar.gz";
FileOutputStream fout = new FileOutputStream(filename);
CompressorOu... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void submitRequest(String url, String queryName, String destination){
HttpResponse response = null;
InputStream responseStream = null;
try{
HttpClient client = getClient();
FileOutputStream fos = new FileOutputStream(destination);
... | #vulnerable code
public void submitRequest(String url, String queryName, String destination){
HttpResponse response = null;
InputStream responseStream = null;
try{
FileOutputStream fos = new FileOutputStream(destination);
HttpGet httpget = new HttpGe... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private List<Issue> parse(File report) throws IOException {
List<Issue> issues = new LinkedList<>();
PylintReportParser parser = new PylintReportParser();
Scanner sc;
for (sc = new Scanner(report.toPath(), fileSystem.encoding().name()); sc.hasNext(); ) {
... | #vulnerable code
private List<Issue> parse(File report) throws IOException {
List<Issue> issues = new LinkedList<>();
PylintReportParser parser = new PylintReportParser();
for (Scanner sc = new Scanner(report.toPath(), fileSystem.encoding().name()); sc.hasNext(); ) {
St... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void while_statement() {
setRootRule(PythonGrammar.WHILE_STMT);
WhileStatementImpl tree = parse("while foo:\n pass\nelse:\n pass", treeMaker::whileStatement);
FirstLastTokenVerifierVisitor visitor = spy(FirstLastTokenVerifierVisitor.class);
visi... | #vulnerable code
@Test
public void while_statement() {
setRootRule(PythonGrammar.WHILE_STMT);
WhileStatementImpl tree = parse("while foo:\n pass\nelse:\n pass", treeMaker::whileStatement);
FirstLastTokenVerifierVisitor visitor = spy(FirstLastTokenVerifierVisitor.class);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static List<String> callCommand(String command, String[] environ) {
List<String> lines = new LinkedList<String>();
PythonPlugin.LOG.debug("Calling command: '{}'", command);
BufferedReader stdInput = null;
Process process = null;
try {
if(envir... | #vulnerable code
public static List<String> callCommand(String command, String[] environ) {
List<String> lines = new LinkedList<String>();
PythonPlugin.LOG.debug("Calling command: '{}'", command);
BufferedReader stdInput = null;
try {
Process p = null;
if(env... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public ForStatement forStatement(AstNode astNode) {
AstNode forStatementNode = astNode;
Token asyncToken = null;
if (astNode.is(PythonGrammar.ASYNC_STMT)) {
asyncToken = toPyToken(astNode.getFirstChild().getToken());
forStatementNode = astNode.getFirstCh... | #vulnerable code
public ForStatement forStatement(AstNode astNode) {
AstNode forStatementNode = astNode;
Token asyncToken = null;
if (astNode.is(PythonGrammar.ASYNC_STMT)) {
asyncToken = toPyToken(astNode.getFirstChild().getToken());
forStatementNode = astNode.getF... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void definition_callee_symbol() {
FileInput tree = parse(
"def fn(): pass",
"fn('foo')"
);
assertNameAndQualifiedName(tree, "fn", null);
} | #vulnerable code
@Test
public void definition_callee_symbol() {
FileInput tree = parse(
"def fn(): pass",
"fn('foo')"
);
// TODO: create a symbol for function declaration
CallExpression callExpression = getCallExpression(tree);
assertThat(callExpression.c... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void relative_import_symbols() {
FileInput tree = parse(
new SymbolTableBuilder("my_package", "my_module.py"),
"from . import b"
);
Name b = getFirstChild(tree, t -> t.is(Tree.Kind.NAME));
assertThat(b.symbol().fullyQualifiedName()).is... | #vulnerable code
@Test
public void relative_import_symbols() {
FileInput tree = parse(
new SymbolTableBuilder("my_package.my_module"),
"from . import b"
);
Name b = getFirstChild(tree, t -> t.is(Tree.Kind.NAME));
assertThat(b.symbol().fullyQualifiedName()).is... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private List<Issue> parse(File report) throws IOException {
List<Issue> issues = new LinkedList<Issue>();
PylintReportParser parser = new PylintReportParser();
for(Scanner sc = new Scanner(report.toPath(), fileSystem.encoding().name()); sc.hasNext(); ) {
Stri... | #vulnerable code
private List<Issue> parse(File report) throws java.io.FileNotFoundException {
List<Issue> issues = new LinkedList<Issue>();
PylintReportParser parser = new PylintReportParser();
for(Scanner sc = new Scanner(report); sc.hasNext(); ) {
String line = sc.ne... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public int size() {
Long size = Objects.requireNonNull(JedisUtil.getJedis()).dbSize();
return size.intValue();
} | #vulnerable code
@Override
public int size() {
Long size = JedisUtil.getJedis().dbSize();
return size.intValue();
}
#location 3
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
String token = (String) auth.getCredentials();
// 解密获得account,用于和数据库进行对比
String account = JWTUtil.getClaim(token, "account");
... | #vulnerable code
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken auth) throws AuthenticationException {
String token = (String) auth.getCredentials();
// 解密获得account,用于和数据库进行对比
String account = JWTUtil.getClaim(token, "accou... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public Set keys() {
Set<byte[]> keys = Objects.requireNonNull(JedisUtil.getJedis()).keys("*".getBytes());
Set<Object> set = new HashSet<Object>();
for (byte[] bs : keys) {
set.add(SerializableUtil.unserializable(bs));
... | #vulnerable code
@Override
public Set keys() {
Set<byte[]> keys = JedisUtil.getJedis().keys(new String("*").getBytes());
Set<Object> set = new HashSet<Object>();
for (byte[] bs : keys) {
set.add(SerializableUtil.unserializable(bs));
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public void clear() throws CacheException {
Objects.requireNonNull(JedisUtil.getJedis()).flushDB();
} | #vulnerable code
@Override
public void clear() throws CacheException {
JedisUtil.getJedis().flushDB();
}
#location 3
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private HashSet<String> extractOutputVariables(String stateMachineText) throws IOException {
Set<String> names = ScXmlUtils.getAttributesValues(stateMachineText, "assign", "name");
return (HashSet<String>) names;
} | #vulnerable code
private HashSet<String> extractOutputVariables(String stateMachineText) throws IOException {
InputStream is = new ByteArrayInputStream(stateMachineText.getBytes());
BufferedReader bReader = new BufferedReader(new InputStreamReader(is));
HashSet<... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Test
public void testDefaultDataConsumerAccess() {
DataPipe thePipe = new DataPipe();
DataConsumer dc = thePipe.getDataConsumer();
dc.setFlags(new Hashtable<String, AtomicBoolean>());
Assert.assertNotNull(dc);
Assert.assertNotNull... | #vulnerable code
@Test
public void testDefaultDataConsumerAccess(){
DataPipe thePipe = new DataPipe();
DataConsumer dc = thePipe.getDataConsumer();
Assert.assertNotNull(dc);
Assert.assertNotNull(dc.getFlags());
Assert.assertFalse(dc.getFlags(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public String getProperty(String name) {
Properties properties = new Properties();
FileInputStream fileInputStream = null;
String value = null;
try {
fileInputStream = new FileInputStream(this.getProperties());
properties.load(fileInputStream);
value = propertie... | #vulnerable code
public String getProperty(String name) {
Properties properties = new Properties();
Resource resource = new ClassPathResource("server.properties");
FileInputStream fileInputStream = null;
String value = null;
try {
fileInputStream = new FileInputStream(resource... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@RequestMapping("/file/downloadFile")
@ResponseBody
public void downloadFile(String path, String name, HttpServletRequest request, HttpServletResponse response) {
response.setHeader("Content-Disposition", "attachment;filename=" + name);
response.setCon... | #vulnerable code
@RequestMapping("/file/downloadFile")
@ResponseBody
public void downloadFile(String path, String name, HttpServletRequest request, HttpServletResponse response) {
response.setHeader("Content-Disposition", "attachment;filename=" + name);
response.... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void addSuper(@NotNull Type superclass) {
this.superclass = superclass;
table.setSuper(superclass.table);
} | #vulnerable code
public void addSuper(@NotNull Type superclass) {
this.superclass = superclass;
table.addSuper(superclass.table);
}
#location 3
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Nullable
public String extendPath(@NotNull String name) {
if (name.endsWith(".py")) {
name = Util.moduleNameFor(name);
}
if (path.equals("")) {
return name;
}
String sep;
switch (scopeType) {
... | #vulnerable code
@Nullable
public String extendPath(@NotNull String name) {
if (name.endsWith(".py")) {
name = Util.moduleNameFor(name);
}
if (path.equals("")) {
return name;
}
String sep;
switch (scopeType) {
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@NotNull
public List<Entry> generate(@NotNull Scope scope, @NotNull String path) {
List<Entry> result = new ArrayList<Entry>();
Set<Binding> entries = new TreeSet<Binding>();
for (Binding b : scope.values()) {
if (!b.isSynthetic()
... | #vulnerable code
@NotNull
public List<Entry> generate(@NotNull Scope scope, @NotNull String path) {
List<Entry> result = new ArrayList<Entry>();
Set<Binding> entries = new TreeSet<Binding>();
for (Binding b : scope.values()) {
if (!b.isSynthetic(... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
String[] list(String... names) {
return names;
} | #vulnerable code
void buildTupleType() {
Scope bt = BaseTuple.getTable();
String[] tuple_methods = {
"__add__", "__contains__", "__eq__", "__ge__", "__getnewargs__",
"__gt__", "__iter__", "__le__", "__len__", "__lt__", "__mul__",
"__ne... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void setAttrType(@NotNull Type targetType, @NotNull Type v) {
if (targetType.isUnknownType()) {
Analyzer.self.putProblem(this, "Can't set attribute for UnknownType");
return;
}
// new attr, mark the type as "mutated"
... | #vulnerable code
private void setAttrType(@NotNull Type targetType, @NotNull Type v) {
if (targetType.isUnknownType()) {
Analyzer.self.putProblem(this, "Can't set attribute for UnknownType");
return;
}
// new attr, mark the type as "mutate... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public int compareTo(@NotNull Object o) {
return getSingle().getStart() - ((Binding)o).getSingle().getStart();
} | #vulnerable code
public int compareTo(@NotNull Object o) {
return getFirstNode().getStart() - ((Binding)o).getFirstNode().getStart();
}
#location 2
#vulnerability type NULL_DEREFERENCE | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public boolean equals(Object obj) {
if (obj instanceof Function) {
Function fo = (Function) obj;
return (fo.file.equals(file) && fo.start == start);
} else {
return false;
}
} | #vulnerable code
@Override
public boolean equals(Object obj) {
if (obj instanceof Function) {
Function fo = (Function) obj;
return (fo.getFile().equals(getFile()) && fo.start == start);
} else {
return false;
}
}
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public void restrictNumType(Compare compare, Scope s1, Scope s2) {
List<Node> ops = compare.ops;
if (ops.size() > 0 && ops.get(0) instanceof Op) {
Op op = ((Op) ops.get(0));
String opname = op.name;
if (op.isNumberCompariso... | #vulnerable code
public void restrictNumType(Compare compare, Scope s1, Scope s2) {
List<Node> ops = compare.ops;
if (ops.size() > 0 && ops.get(0) instanceof Op) {
String opname = ((Op) ops.get(0)).name;
Node left = compare.left;
Node... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@NotNull
@Override
public Type transform(@NotNull State s) {
if (locator != null) {
Type existing = transformExpr(locator, s);
if (existing instanceof ClassType) {
if (body != null) {
transformExpr(bo... | #vulnerable code
@NotNull
@Override
public Type transform(@NotNull State s) {
ClassType classType = new ClassType(getName().id, s);
List<Type> baseTypes = new ArrayList<>();
for (Node base : bases) {
Type baseType = transformExpr(base, s);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public static void bindIter(@NotNull Scope s, Node target, @NotNull Node iter, Binding.Kind kind) {
Type iterType = Node.resolveExpr(iter, s);
if (iterType.isListType()) {
bind(s, target, iterType.asListType().getElementType(), kind);
} el... | #vulnerable code
public static void bindIter(@NotNull Scope s, Node target, @NotNull Node iter, Binding.Kind kind) {
Type iterType = Node.resolveExpr(iter, s);
if (iterType.isListType()) {
bind(s, target, iterType.asListType().getElementType(), kind);
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@NotNull
@Override
public Type transform(State s) {
Type ltype = transformExpr(left, s);
Type rtype;
// boolean operations
if (op == Op.And) {
if (ltype.isUndecidedBool()) {
rtype = transformExpr(right, lty... | #vulnerable code
@NotNull
@Override
public Type transform(State s) {
Type ltype = transformExpr(left, s);
Type rtype;
// boolean operations
if (op == Op.And) {
if (ltype.isUndecidedBool()) {
rtype = transformExpr(righ... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
String[] list(String... names) {
return names;
} | #vulnerable code
void buildFunctionType() {
Scope t = BaseFunction.getTable();
for (String s : list("func_doc", "__doc__", "func_name", "__name__", "__module__")) {
t.update(s, new Url(DATAMODEL_URL), BaseStr, ATTRIBUTE);
}
Binding b = synth... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
private void createStreams(final String host) throws Exception {
appServerPort = randomFreeLocalPort();
streams = KafkaMusicExample.createChartsStreams(CLUSTER.bootstrapServers(),
CLUSTER.schemaRegistryUrl(),
... | #vulnerable code
private void createStreams(final String host) throws Exception {
appServerPort = randomFreeLocalPort();
streams = KafkaMusicExample.createChartsStreams(CLUSTER.bootstrapServers(),
CLUSTER.schemaRegistryUrl(),
... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
@Override
public ReturnT<String> add(XxlConfNode xxlConfNode, XxlConfUser loginUser, String loginEnv) {
// valid
if (StringUtils.isBlank(xxlConfNode.getAppname())) {
return new ReturnT<String>(500, "AppName不可为空");
}
// project permission
if (!ifHasProjectPermissi... | #vulnerable code
@Override
public ReturnT<String> add(XxlConfNode xxlConfNode, XxlConfUser loginUser, String loginEnv) {
// valid
if (StringUtils.isBlank(xxlConfNode.getAppname())) {
return new ReturnT<String>(500, "AppName不可为空");
}
// project permission
if (!ifHasProjectPe... | Below is the vulnerable code, please generate the patch based on the following information. |
#fixed code
public ZooKeeper getClient(){
if (zooKeeper == null) {
try {
zooKeeper = new ZooKeeper(zkaddress, 10000, watcher); // TODO,本地变量方式,成功才会赋值
if (zkdigest != null && zkdigest.trim().length() > 0) {
zooKeep... | #vulnerable code
public ZooKeeper getClient(){
if (zooKeeper==null) {
try {
if (INSTANCE_INIT_LOCK.tryLock(2, TimeUnit.SECONDS)) {
if (zooKeeper==null) { // 二次校验,防止并发创建client
try {
zooKeeper = new ZooKeeper(zkaddress, 10000, watcher); // TODO,本地变量方式,成功才会赋值
... | Below is the vulnerable code, please generate the patch based on the following information. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.