Security Aware Code
Collection
4 items • Updated
bug_id stringlengths 22 44 | func_before stringlengths 101 9.03k | func_after stringlengths 161 12.3k |
|---|---|---|
aws-aws-secretsmanager-jdbc-d25e52d637cf | @Override
public String constructUrlFromEndpointPortDatabase(String endpoint, String port, String dbname) {
String url = "jdbc:postgresql://" + endpoint;
if (!StringUtils.isNullOrEmpty(port)) {
url += ":" + port;
}
if (!StringUtils.isNullOrEmpty(dbname)) {
... | @Override
public String constructUrlFromEndpointPortDatabase(String endpoint, String port, String dbname) {
String url = "jdbc:postgresql://" + endpoint;
if (!StringUtils.isNullOrEmpty(port)) {
url += ":" + port;
}
url += "/";
if (!StringUtils.isNullOrEmpty(db... |
jitterted-ensembler-14a39138787f | public void acceptedBy(MemberId memberId) {
requireNotCompleted();
requireNotCanceled();
requireHasSpace();
membersWhoAccepted.add(memberId);
membersWhoDeclined.remove(memberId);
}
| public void acceptedBy(MemberId memberId) {
requireNotCompleted();
requireNotCanceled();
requireHasSpace();
membersWhoAccepted.add(memberId);
membersWhoDeclined.remove(memberId);
membersAsSpectators.remove(memberId);
}
|
dmak-jaxb-xew-plugin-f48935133d6a | private void moveClassLevelUp(Outline outline, JDefinedClass clazz) {
JDefinedClass parent = (JDefinedClass) clazz.parentContainer();
JClassContainer grandParent = parent.parentContainer();
Map<String, JDefinedClass> classes;
if (grandParent.isClass()) {
JDefinedClass grandParentClass = (JDefinedClass) gran... | private void moveClassLevelUp(Outline outline, JDefinedClass clazz) {
JDefinedClass parent = (JDefinedClass) clazz.parentContainer();
JClassContainer grandParent = parent.parentContainer();
Map<String, JDefinedClass> classes;
if (grandParent.isClass()) {
JDefinedClass grandParentClass = (JDefinedClass) gran... |
jhy-jsoup-5f20fcc2f728 | public Safelist addTags(String... tags) {
Validate.notNull(tags);
for (String tagName : tags) {
Validate.notEmpty(tagName);
tagNames.add(TagName.valueOf(tagName));
}
return this;
}
| public Safelist addTags(String... tags) {
Validate.notNull(tags);
for (String tagName : tags) {
Validate.notEmpty(tagName);
Validate.isFalse(tagName.equalsIgnoreCase("noscript"),
"noscript is unsupported in Safelists, due to incompatibilities between parsers w... |
crowdin-crowdin-api-client-java-f0f22b2b56d7 | public JacksonJsonTransformer() {
ObjectMapper cleanObjectMapper = new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
SimpleModule enumModule = new SimpleModule()
.addDeserializer(Enum.class, new EnumDeserializer());
SimpleModule ... | public JacksonJsonTransformer() {
ObjectMapper cleanObjectMapper = new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
SimpleModule enumModule = new SimpleModule()
.addDeserializer(Enum.class, new EnumDeserializer());
SimpleModule ... |
stellar-java-stellar-sdk-1461c2fc5b89 | public boolean isSorobanTransaction() {
if (mOperations.length != 1) {
return false;
}
Operation op = mOperations[0];
return op instanceof InvokeHostFunctionOperation
|| op instanceof BumpSequenceOperation
|| op instanceof RestoreFootprintOperation;
}
| public boolean isSorobanTransaction() {
if (mOperations.length != 1) {
return false;
}
Operation op = mOperations[0];
return op instanceof InvokeHostFunctionOperation
|| op instanceof BumpFootprintExpirationOperation
|| op instanceof RestoreFootprintOperation;
}
|
traccar-traccar-65f54c200cf0 | private void decodeLocation(Position position, ByteBuf buf, int codec, String model) {
int globalMask = 0x0f;
if (codec == CODEC_GH3000) {
long time = buf.readUnsignedInt() & 0x3fffffff;
time += 1167609600;
globalMask = buf.readUnsignedByte();
if (Bit... | private void decodeLocation(Position position, ByteBuf buf, int codec, String model) {
int globalMask = 0x0f;
if (codec == CODEC_GH3000) {
long time = buf.readUnsignedInt() & 0x3fffffff;
time += 1167609600;
globalMask = buf.readUnsignedByte();
if (Bit... |
mthmulders-mcs-eff905bef8d8 | private void printRow(final Help.TextTable table, final SearchResponse.Response.Doc doc) {
var lastUpdated = DATE_TIME_FORMATTER.format(
Instant.ofEpochMilli(doc.timestamp()).atZone(ZoneId.systemDefault())
);
table.addRowValues(doc.id(), lastUpdated);
}
| private void printRow(final Help.TextTable table, final SearchResponse.Response.Doc doc) {
var lastUpdated = DATE_TIME_FORMATTER.format(
Instant.ofEpochMilli(doc.timestamp()).atZone(ZoneId.systemDefault())
);
table.addRowValues(doc.id() + ":" + doc.latestVersion(), lastUpdate... |
traccar-traccar-fdbd269b9b99 | private Object decodePosition(
Channel channel, SocketAddress remoteAddress, String sentence, String id) {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, id);
if (deviceSession == null) {
return null;
}
List<Position> positions = new Li... | private Object decodePosition(
Channel channel, SocketAddress remoteAddress, String sentence, String id) {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, id);
if (deviceSession == null) {
return null;
}
List<Position> positions = new Li... |
traccar-traccar-8b4d3ee0b964 | @Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
String sentence = (String) msg;
if (sentence.startsWith("!1,")) {
int index = sentence.indexOf(',', 3);
if (index < 0) {
index = sen... | @Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
String sentence = (String) msg;
if (sentence.startsWith("!1,")) {
int index = sentence.indexOf(',', 3);
if (index < 0) {
index = sen... |
traccar-traccar-e73f36db83b9 | private Object decodeEri(Channel channel, SocketAddress remoteAddress, String sentence) {
Parser parser = new Parser(PATTERN_ERI, sentence);
if (!parser.matches()) {
return null;
}
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
... | private Object decodeEri(Channel channel, SocketAddress remoteAddress, String sentence) {
Parser parser = new Parser(PATTERN_ERI, sentence);
if (!parser.matches()) {
return null;
}
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
... |
AuthMe-ConfigMe-aa91a6b315ec | public void setComment(@NotNull String path, @NotNull String... commentLines) {
comments.put(path, Collections.unmodifiableList(Arrays.asList(commentLines)));
}
| public void setComment(@NotNull String path, @NotNull String... commentLines) {
List<String> replaced = comments.put(path, Collections.unmodifiableList(Arrays.asList(commentLines)));
if (replaced != null) {
throw new IllegalStateException("Comment lines already exists for the path '" + p... |
traccar-traccar-8de9a36abef8 | private void decodeFragment(Position position, String fragment) {
int dataIndex = fragment.indexOf(':');
int index = 0;
String[] values;
if (fragment.length() == dataIndex + 1) {
values = new String[0];
} else {
values = fragment.substring(dataIndex + ... | private void decodeFragment(Position position, String fragment) {
int dataIndex = fragment.indexOf(':');
int index = 0;
String[] values;
if (fragment.length() == dataIndex + 1) {
values = new String[0];
} else {
values = fragment.substring(dataIndex + ... |
traccar-traccar-392f00082faf | private List<Position> decodeBinaryE(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
List<Position> positions = new LinkedList<>();
buf.readerIndex(buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ',') + 1);
String imei = buf.readSlice(15).toString(StandardCharsets.US_AS... | private List<Position> decodeBinaryE(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
List<Position> positions = new LinkedList<>();
buf.readerIndex(buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ',') + 1);
String imei = buf.readSlice(15).toString(StandardCharsets.US_AS... |
cloudsimplus-cloudsimplus-61c8b942d1ec | public HostAbstract(final List<Pe> peList, final boolean activate) {
this(defaultBwCapacity, defaultStorageCapacity, new HarddriveStorage(defaultRamCapacity), peList, activate);
}
| public HostAbstract(final List<Pe> peList, final boolean activate) {
this(defaultRamCapacity, defaultBwCapacity, new HarddriveStorage(defaultStorageCapacity), peList, activate);
}
|
traccar-traccar-3771dd156efb | private Position decodePosition(DeviceSession deviceSession, String data) {
Parser parser = new Parser(PATTERN_POSITION, data);
if (!parser.matches()) {
return null;
}
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDevic... | private Position decodePosition(DeviceSession deviceSession, String data) {
Parser parser = new Parser(PATTERN_POSITION, data);
if (!parser.matches()) {
return null;
}
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDevic... |
traccar-traccar-dfc546a26f5b | private List<Position> decodeBinaryE(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
List<Position> positions = new LinkedList<>();
buf.readerIndex(buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ',') + 1);
String imei = buf.readSlice(15).toString(StandardCharsets.US_AS... | private List<Position> decodeBinaryE(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
List<Position> positions = new LinkedList<>();
buf.readerIndex(buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ',') + 1);
String imei = buf.readSlice(15).toString(StandardCharsets.US_AS... |
traccar-traccar-3331593759a2 | private Position decodeTransparent(DeviceSession deviceSession, ByteBuf buf) {
int type = buf.readUnsignedByte();
if (type == 0xF0) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
Date time = readDate(buf, ... | private Position decodeTransparent(DeviceSession deviceSession, ByteBuf buf) {
int type = buf.readUnsignedByte();
if (type == 0xF0) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
Date time = readDate(buf, ... |
semver4j-semver4j-10102b374298 | @Override
public String toString() {
return rangesList.stream()
.map(RangesList::formatRanges)
.collect(joining(OR_JOINER));
}
| @Override
public String toString() {
return rangesList.stream()
.map(RangesList::formatRanges)
.collect(joining(OR_JOINER))
.replaceAll("^\\(([^()]+)\\)$", "$1");
}
|
nikoo28-java-solutions-8d81307ea165 | public int[] calculateSpans(int[] prices) {
int[] spans = new int[prices.length];
spans[0] = 1;
Stack<Integer> indexStack = new Stack<>();
indexStack.push(0);
for (int i = 1; i < prices.length; i++) {
while (!indexStack.isEmpty()
&& prices[indexStack.peek()] <= prices[i])
... | public int[] calculateSpans(int[] prices) {
int[] spans = new int[prices.length];
spans[0] = 1;
Stack<Integer> indexStack = new Stack<>();
indexStack.push(0);
for (int i = 1; i < prices.length; i++) {
while (!indexStack.isEmpty()
&& prices[indexStack.peek()] < prices[i])
i... |
traccar-traccar-5a1a8d9192ee | @Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ByteBuf buf = (ByteBuf) msg;
buf.readUnsignedByte();
buf.readUnsignedShort();
buf.readUnsignedByte();
buf.readUnsignedShort();
buf.readU... | @Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ByteBuf buf = (ByteBuf) msg;
buf.readUnsignedByte();
buf.readUnsignedShort();
buf.readUnsignedByte();
buf.readUnsignedShort();
buf.readU... |
jitterted-ensembler-0963194c9ebc | public static ParticipantAction from(MemberStatus memberStatus, boolean disabled) {
return switch (memberStatus) {
case UNKNOWN, DECLINED -> new ParticipantAction(
"/member/accept",
"Participate in Rotation ⌨",
disabled);
... | public static ParticipantAction from(MemberStatus memberStatus, boolean disabled) {
return switch (memberStatus) {
case UNKNOWN, DECLINED -> new ParticipantAction(
"/member/accept",
"Participate in Rotation ⌨",
disabled);
... |
jitterted-ensembler-0e512e5b3677 | public static EnsembleSummaryView toView(Ensemble ensemble, MemberId memberId, MemberService memberService) {
List<MemberView> participantViews = transform(memberService, ensemble.acceptedMembers());
return new EnsembleSummaryView(ensemble.getId().id(),
ensembl... | public static EnsembleSummaryView toView(Ensemble ensemble, MemberId memberId, MemberService memberService) {
List<MemberView> participantViews = transform(memberService, ensemble.acceptedMembers());
List<MemberView> spectatorViews = transform(memberService, ensemble.spectators());
return ne... |
jitterted-ensembler-60ec3bf0273b | public void joinAsSpectator(MemberId memberId) {
membersAsSpectators.add(memberId);
membersWhoAccepted.remove(memberId);
}
| public void joinAsSpectator(MemberId memberId) {
membersAsSpectators.add(memberId);
membersWhoAccepted.remove(memberId);
membersWhoDeclined.remove(memberId);
}
|
traccar-traccar-ee3cbd4aba2e | private Position decodeLocation2(DeviceSession deviceSession, ByteBuf buf, int type) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
Jt600ProtocolDecoder.decodeBinaryLocation(buf, position);
position.setValid(type != MSG_LOCAT... | private Position decodeLocation2(DeviceSession deviceSession, ByteBuf buf, int type) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
Jt600ProtocolDecoder.decodeBinaryLocation(buf, position);
position.setValid(type != MSG_LOCAT... |
fishercoder1534-Leetcode-2110c6b023b7 | public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
if (root == null || p == root || q == root) {
return root;
}
if ((root.val - p.val) * (root.val - q.val) > 0) {
if (root.val - p.val > 0) {
return... | public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {
if (root == null || p == root || q == root) {
return root;
}
if (root.val > p.val && root.val > q.val) {
return lowestCommonAncestor(root.left, p, q);
} e... |
jhy-jsoup-8e2b86839b27 | private boolean isFormatAsBlock(Document.OutputSettings out) {
return tag.formatAsBlock() || (parent() != null && parent().tag().formatAsBlock()) || out.outline();
}
| private boolean isFormatAsBlock(Document.OutputSettings out) {
return tag.isBlock() || (parent() != null && parent().tag().formatAsBlock()) || out.outline();
}
|
traccar-traccar-cadcd2676adb | @Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2);
int type = buf.readUnsignedByte();
buf.readUnsignedShort();
if (type == MSG_LOGIN || type == MSG_AD... | @Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2);
int type = buf.readUnsignedByte();
buf.readUnsignedShort();
if (type == MSG_LOGIN || type == MSG_AD... |
traccar-traccar-1a1126d2d392 | private Position decode4(
Channel channel, SocketAddress remoteAddress, String[] values) throws ParseException {
int index = 0;
String type = values[index++].substring(5);
if (!type.equals("STT") && !type.equals("ALT")) {
return null;
}
DeviceSession d... | private Position decode4(
Channel channel, SocketAddress remoteAddress, String[] values) throws ParseException {
int index = 0;
String type = values[index++].substring(5);
if (!type.equals("STT") && !type.equals("ALT")) {
return null;
}
DeviceSession d... |
jhy-jsoup-a349582236a7 | private boolean isInlineable(Document.OutputSettings out) {
return tag().isInline()
&& (parent() == null || parent().isBlock())
&& previousSibling() != null
&& !out.outline();
}
| private boolean isInlineable(Document.OutputSettings out) {
if (!tag.isInline())
return false;
final Node prev = previousSibling();
boolean isFirst = siblingIndex == 0;
if (siblingIndex == 1 && prev instanceof TextNode && (((TextNode) prev).isBlank()))
isFirst... |
jhy-jsoup-2a4a9cf83dea | @Override
public boolean matches(Element root, Element element) {
for (int i = evaluators.size() -1; i >= 0; --i) {
if (element == null)
return false;
Evaluator eval = evaluators.get(i);
if (!eval.matches(root, element))
... | @Override
public boolean matches(Element root, Element element) {
if (element == root)
return false;
for (int i = evaluators.size() -1; i >= 0; --i) {
if (element == null)
return false;
Evaluator eval = evaluato... |
traccar-traccar-d797671b2ce6 | private Position decodeTransparent(DeviceSession deviceSession, ByteBuf buf) {
int type = buf.readUnsignedByte();
if (type == 0xF0) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
Date time = readDate(buf, ... | private Position decodeTransparent(DeviceSession deviceSession, ByteBuf buf) {
int type = buf.readUnsignedByte();
if (type == 0xF0) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
Date time = readDate(buf, ... |
traccar-traccar-779486a30483 | protected Object decodeAvrmc(
String sentence, Channel channel, SocketAddress remoteAddress) {
Parser parser = new Parser(PATTERN_AVRMC, sentence);
if (!parser.matches()) {
return null;
}
DeviceSession deviceSession =
getDeviceSession(channel, remo... | protected Object decodeAvrmc(
String sentence, Channel channel, SocketAddress remoteAddress) {
Parser parser = new Parser(PATTERN_AVRMC, sentence);
if (!parser.matches()) {
return null;
}
DeviceSession deviceSession =
getDeviceSession(channel, remo... |
traccar-traccar-4ece72558c80 | private List<Position> parseData(
Channel channel, SocketAddress remoteAddress, ByteBuf buf, int locationPacketId, String... imei) {
List<Position> positions = new LinkedList<>();
if (!connectionless) {
buf.readUnsignedInt();
}
int codec = buf.readUnsignedByt... | private List<Position> parseData(
Channel channel, SocketAddress remoteAddress, ByteBuf buf, int locationPacketId, String... imei) {
List<Position> positions = new LinkedList<>();
if (!connectionless) {
buf.readUnsignedInt();
}
int codec = buf.readUnsignedByt... |
jhy-jsoup-6ccd158754e2 | private static void appendToAscii(String s, boolean spaceAsPlus, StringBuilder sb) throws UnsupportedEncodingException {
for (int i = 0; i < s.length(); i++) {
int c = s.codePointAt(i);
if (c == ' ') {
sb.append(spaceAsPlus ? '+' : "%20");
} else if (c > 1... | private static void appendToAscii(String s, boolean spaceAsPlus, StringBuilder sb) throws UnsupportedEncodingException {
for (int i = 0; i < s.length(); i++) {
int c = s.codePointAt(i);
if (c == ' ') {
sb.append(spaceAsPlus ? '+' : "%20");
} else if (c > 1... |
snowflakedb-snowflake-jdbc-f2c8eba73535 | static boolean isNonRetryableHTTPCode(CloseableHttpResponse response, boolean retryHTTP403) {
return response != null
&& (response.getStatusLine().getStatusCode() < 500
||
response.getStatusLine().getStatusCode() >= 600)
&&
response.getStatusLine().getStatusCode()... | static boolean isNonRetryableHTTPCode(CloseableHttpResponse response, boolean retryHTTP403) {
return response != null
&& (response.getStatusLine().getStatusCode() < 500
||
response.getStatusLine().getStatusCode() >= 600)
&&
response.getStatusLine().getStatusCode()... |
traccar-traccar-4a5b8d79b560 | @Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
String sentence = (String) msg;
sentence = sentence.substring(sentence.indexOf('|') + 1, sentence.lastIndexOf('|'));
Position position = new Position();
pos... | @Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
String sentence = (String) msg;
sentence = sentence.substring(sentence.indexOf('|') + 1, sentence.lastIndexOf('|'));
Position position = new Position();
pos... |
traccar-traccar-6631d7c4b352 | @Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
int endIndex = -1;
for (int i = buf.writerIndex() - 1; i >= buf.readerIndex(); i--) {
if (buf.getByte(i) == ']') {
endIndex = i + 1;
... | @Override
protected Object decode(
ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
int brackets = 0;
int endIndex = -1;
for (int i = buf.readerIndex(); i < buf.writerIndex(); i++) {
byte b = buf.getByte(i);
switch (b) {
... |
jhy-jsoup-9e5869b6e1e2 | void outerHtmlHead(Appendable accum, int depth, Document.OutputSettings out) throws IOException {
final boolean prettyPrint = out.prettyPrint();
final Element parent = parentNode instanceof Element ? ((Element) parentNode) : null;
final boolean normaliseWhite = prettyPrint && !Element.preser... | void outerHtmlHead(Appendable accum, int depth, Document.OutputSettings out) throws IOException {
final boolean prettyPrint = out.prettyPrint();
final Element parent = parentNode instanceof Element ? ((Element) parentNode) : null;
final boolean normaliseWhite = prettyPrint && !Element.preser... |
stellar-java-stellar-sdk-15cc6d2c8131 | @Override
public boolean equals(Object object) {
if (!(object instanceof KeyPair)) {
return false;
}
KeyPair other = (KeyPair) object;
return this.mPrivateKey.equals(other.mPrivateKey) &&
this.mPublicKey.equals(other.mPublicKey);
}
| @Override
public boolean equals(Object object) {
if (!(object instanceof KeyPair)) {
return false;
}
KeyPair other = (KeyPair) object;
return Objects.equal(this.mPrivateKey, other.mPrivateKey) &&
this.mPublicKey.equals(other.mPublicKey);
}
|
jhy-jsoup-9bb07d2ab43c | protected void replaceChild(Node out, Node in) {
Validate.isTrue(out.parentNode == this);
Validate.notNull(in);
if (in.parentNode != null)
in.parentNode.removeChild(in);
final int index = out.siblingIndex;
ensureChildNodes().set(index, in);
in.parentNode =... | protected void replaceChild(Node out, Node in) {
Validate.isTrue(out.parentNode == this);
Validate.notNull(in);
if (out == in) return;
if (in.parentNode != null)
in.parentNode.removeChild(in);
final int index = out.siblingIndex;
ensureChildNodes().set(ind... |