code stringlengths 12 2.05k | label_name stringlengths 6 8 | label int64 0 95 |
|---|---|---|
int HttpFileImpl::save(const std::string &path) const
{
assert(!path.empty());
if (fileName_.empty())
return -1;
filesystem::path fsPath(utils::toNativePath(path));
if (!fsPath.is_absolute() &&
(!fsPath.has_parent_path() ||
(fsPath.begin()->string() != "." && fsPath.begin()->str... | CWE-552 | 69 |
static String HHVM_FUNCTION(bcsub, const String& left, const String& right,
int64_t scale /* = -1 */) {
if (scale < 0) scale = BCG(bc_precision);
bc_num first, second, result;
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&result);
php_str2num(&first, (char*)left.data())... | CWE-190 | 19 |
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
auto* params =
reinterpret_cast<TfLiteResizeBilinearParams*>(node->builtin_data);
const TfLiteTensor* input = GetInput(context, node, kInputTensor);
TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
const TfLiteTensor* size = Get... | CWE-125 | 47 |
inline void StringData::setSize(int len) {
assertx(!isImmutable() && !hasMultipleRefs());
assertx(len >= 0 && len <= capacity());
mutableData()[len] = 0;
m_lenAndHash = len;
assertx(m_hash == 0);
assertx(checkSane());
} | CWE-125 | 47 |
static bool MR_primality_test(UnsignedBigInteger n, const Vector<UnsignedBigInteger, 256>& tests)
{
// Written using Wikipedia:
// https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test#Miller%E2%80%93Rabin_test
ASSERT(!(n < 4));
auto predecessor = n.minus({ 1 });
auto d = predecessor;
... | CWE-120 | 44 |
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
auto* params = reinterpret_cast<TfLiteSubParams*>(node->builtin_data);
OpData* data = reinterpret_cast<OpData*>(node->user_data);
const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);
const TfLiteTensor* input2 = GetInput(context, nod... | CWE-125 | 47 |
inline int StringData::size() const { return m_len; } | CWE-190 | 19 |
const TfLiteTensor* GetOptionalInputTensor(const TfLiteContext* context,
const TfLiteNode* node, int index) {
const bool use_tensor = index < node->inputs->size &&
node->inputs->data[index] != kTfLiteOptionalTensor;
if (use_tensor) {
return Ge... | CWE-787 | 24 |
TfLiteStatus EvalLogic(TfLiteContext* context, TfLiteNode* node,
OpContext* op_context, T init_value,
T reducer(const T current, const T in)) {
int64_t num_axis = NumElements(op_context->axis);
TfLiteTensor* temp_index = GetTemporary(context, node, /*index=*/0);
TfLit... | CWE-787 | 24 |
String StringUtil::Crypt(const String& input, const char *salt /* = "" */) {
if (salt && salt[0] == '\0') {
raise_notice("crypt(): No salt parameter was specified."
" You must use a randomly generated salt and a strong"
" hash function to produce a secure hash.");
}
return String(string_crypt(inpu... | CWE-22 | 2 |
TfLiteStatus LeakyReluEval(TfLiteContext* context, TfLiteNode* node) {
const TfLiteTensor* input = GetInput(context, node, 0);
TfLiteTensor* output = GetOutput(context, node, 0);
const auto* params =
reinterpret_cast<TfLiteLeakyReluParams*>(node->builtin_data);
const LeakyReluOpData* data =
reinterp... | CWE-125 | 47 |
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);
TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
// Reinterprete the opaque data provided by user.
OpData* data = reinterpret_cast<OpData*>(node->user_data);
const TfLiteTensor* input1 = GetInput... | CWE-125 | 47 |
void pcre_dump_cache(const std::string& filename) {
s_pcreCache.dump(filename);
} | CWE-22 | 2 |
AP4_VisualSampleEntry::ReadFields(AP4_ByteStream& stream)
{
// sample entry
AP4_Result result = AP4_SampleEntry::ReadFields(stream);
if (result < 0) return result;
// read fields from this class
stream.ReadUI16(m_Predefined1);
stream.ReadUI16(m_Reserved2);
stream.Read(m_Predefined2, sizeof(... | CWE-843 | 43 |
bool MemFile::seek(int64_t offset, int whence /* = SEEK_SET */) {
assertx(m_len != -1);
if (whence == SEEK_CUR) {
if (offset > 0 && offset < bufferedLen()) {
setReadPosition(getReadPosition() + offset);
setPosition(getPosition() + offset);
return true;
}
offset += getPosition();
wh... | CWE-125 | 47 |
int overrun(int itemSize, int nItems) {
int len = ptr - start + itemSize * nItems;
if (len < (end - start) * 2)
len = (end - start) * 2;
U8* newStart = new U8[len];
memcpy(newStart, start, ptr - start);
ptr = newStart + (ptr - start);
delete [] start;
start = newSt... | CWE-787 | 24 |
int TLSOutStream::length()
{
return offset + ptr - start;
} | CWE-787 | 24 |
static float *get_window(vorb *f, int len)
{
len <<= 1;
if (len == f->blocksize_0) return f->window[0];
if (len == f->blocksize_1) return f->window[1];
assert(0);
return NULL;
} | CWE-908 | 48 |
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
const TfLiteTensor* input = GetInput(context, node, kInputTensor);
TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);
TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
TF_LITE_ENSURE_TY... | CWE-125 | 47 |
R_API RBinJavaAttrInfo *r_bin_java_rti_annotations_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {
ut32 i = 0;
RBinJavaAttrInfo *attr = NULL;
ut64 offset = 0;
attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);
offset += 6;
if (attr) {
attr->type = R_BIN_JAVA_ATTR_TYPE_RUNTIME_... | CWE-125 | 47 |
bool TemporaryFile::deleteTemporaryFile() const
{
// Have a few attempts at deleting the file before giving up..
for (int i = 5; --i >= 0;)
{
if (temporaryFile.deleteFile())
return true;
Thread::sleep (50);
}
return false;
}
| CWE-59 | 36 |
Network::FilterStatus Context::onDownstreamData(int data_length, bool end_of_stream) {
if (!wasm_->onDownstreamData_) {
return Network::FilterStatus::Continue;
}
auto result = wasm_->onDownstreamData_(this, id_, static_cast<uint32_t>(data_length),
static_cast<uint32_t>... | CWE-476 | 46 |
otError Commissioner::GeneratePskc(const char * aPassPhrase,
const char * aNetworkName,
const Mac::ExtendedPanId &aExtPanId,
Pskc & aPskc)
{
otError error = ... | CWE-787 | 24 |
static INLINE UINT16 ntlm_av_pair_get_id(const NTLM_AV_PAIR* pAvPair)
{
UINT16 AvId;
Data_Read_UINT16(&pAvPair->AvId, AvId);
return AvId;
} | CWE-125 | 47 |
int DummyOutStream::length()
{
flush();
return offset;
} | CWE-787 | 24 |
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
OpData* data = reinterpret_cast<OpData*>(node->user_data);
const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);
const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);
TfLiteTensor* output = GetOutput(context, node, kOut... | CWE-787 | 24 |
MONGO_EXPORT int bson_append_regex( bson *b, const char *name, const char *pattern, const char *opts ) {
const int plen = strlen( pattern )+1;
const int olen = strlen( opts )+1;
if ( bson_append_estart( b, BSON_REGEX, name, plen + olen ) == BSON_ERROR )
return BSON_ERROR;
if ( bson_check_string(... | CWE-190 | 19 |
virtual ~CxFile() { };
| CWE-770 | 37 |
TfLiteStatus EvalHashtableImport(TfLiteContext* context, TfLiteNode* node) {
const TfLiteTensor* input_resource_id_tensor =
GetInput(context, node, kInputResourceIdTensor);
const int resource_id = input_resource_id_tensor->data.i32[0];
const TfLiteTensor* key_tensor = GetInput(context, node, kKeyTensor);
... | CWE-787 | 24 |
R_API RBinJavaAttrInfo *r_bin_java_source_code_file_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {
if (!sz) {
return NULL;
}
ut64 offset = 0;
RBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);
offset += 6;
if (!attr) {
return NULL;
}
attr->type = R_BIN_J... | CWE-788 | 87 |
unsigned int GetUVarBE(int nPos, int nSize, bool *pbSuccess)
{
//*pbSuccess = true;
if ( nPos < 0 || nPos + nSize > m_nLen )
{
*pbSuccess = false;
return 0;
}
unsigned int nRes = 0;
for ( int nIndex ... | CWE-787 | 24 |
int nego_recv(rdpTransport* transport, wStream* s, void* extra)
{
BYTE li;
BYTE type;
UINT16 length;
rdpNego* nego = (rdpNego*)extra;
if (!tpkt_read_header(s, &length))
return -1;
if (!tpdu_read_connection_confirm(s, &li, length))
return -1;
if (li > 6)
{
/* rdpNegData (optional) */
Stream_Read_UINT8... | CWE-125 | 47 |
void PrivateThreadPoolDatasetOp::MakeDataset(OpKernelContext* ctx,
DatasetBase* input,
DatasetBase** output) {
int64_t num_threads = 0;
OP_REQUIRES_OK(
ctx, ParseScalarArgument<int64_t>(ctx, "num_threads", &num_threads))... | CWE-770 | 37 |
inline int StringData::size() const { return m_len; } | CWE-787 | 24 |
TEST(ImmutableConstantOpTest, FromFile) {
const TensorShape kFileTensorShape({1000, 1});
Env* env = Env::Default();
auto root = Scope::NewRootScope().ExitOnError();
string two_file, three_file;
TF_ASSERT_OK(CreateTempFile(env, 2.0f, 1000, &two_file));
TF_ASSERT_OK(CreateTempFile(env, 3.0f, 1000, &three_fil... | CWE-125 | 47 |
TEST_F(EncryptedRecordTest, TestAllPaddingHandshake) {
addToQueue("17030100050123456789");
EXPECT_CALL(*readAead_, _decrypt(_, _, 0))
.WillOnce(Invoke([](std::unique_ptr<IOBuf>& buf, const IOBuf*, uint64_t) {
expectSame(buf, "0123456789");
return getBuf("16000000");
}));
EXPECT_NO_THRO... | CWE-770 | 37 |
TEST_F(TestSPIFFEValidator, TestGetTrustBundleStore) {
initialize();
// No SAN
auto cert = readCertFromFile(TestEnvironment::substitute(
"{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/extensions_cert.pem"));
EXPECT_FALSE(validator().getTrustBundleStore(cert.get()));
// Non-SPIFFE S... | CWE-295 | 52 |
void pcre_dump_cache(const std::string& filename) {
s_pcreCache.dump(filename);
} | CWE-787 | 24 |
QString Helper::temporaryMountDevice(const QString &device, const QString &name, bool readonly)
{
QString mount_point = mountPoint(device);
if (!mount_point.isEmpty())
return mount_point;
mount_point = "%1/.%2/mount/%3";
const QStringList &tmp_paths = QStandardPaths::standardLocations(QStandar... | CWE-59 | 36 |
TfLiteStatus ReverseSequenceImpl(TfLiteContext* context, TfLiteNode* node) {
const TfLiteTensor* input = GetInput(context, node, kInputTensor);
const TfLiteTensor* seq_lengths_tensor =
GetInput(context, node, kSeqLengthsTensor);
const TS* seq_lengths = GetTensorData<TS>(seq_lengths_tensor);
auto* params ... | CWE-125 | 47 |
void CharToWideMap(const char *Src,wchar *Dest,size_t DestSize,bool &Success)
{
// Map inconvertible characters to private use Unicode area 0xE000.
// Mark such string by placing special non-character code before
// first inconvertible character.
Success=false;
bool MarkAdded=false;
uint SrcPos=0,DestPos=0;... | CWE-787 | 24 |
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
const TfLiteTensor* input = GetInput(context, node, kInputTensor);
const TfLiteTensor* axis_tensor = GetInput(context, node, kAxisTensor);
int axis = GetTensorData<int32_t>(axis_tensor)[0];
const int rank = NumDimensions(input);
if (axis < 0) {
... | CWE-125 | 47 |
Pl_AES_PDF::flush(bool strip_padding)
{
assert(this->offset == this->buf_size);
if (first)
{
first = false;
bool return_after_init = false;
if (this->cbc_mode)
{
if (encrypt)
{
// Set cbc_block to the initialization vector, and if
// not zero, write it to the output stream.
initi... | CWE-787 | 24 |
void MainWindow::on_actionUpgrade_triggered()
{
if (Settings.askUpgradeAutmatic()) {
QMessageBox dialog(QMessageBox::Question,
qApp->applicationName(),
tr("Do you want to automatically check for updates in the future?"),
QMessageBox::No |
QMessageBox::Yes,
... | CWE-295 | 52 |
Status CalculateOutputIndex(OpKernelContext* context, int dimension,
const vector<INDEX_TYPE>& parent_output_index,
INDEX_TYPE output_index_multiplier,
INDEX_TYPE output_size,
vector<INDEX_TYPE>* re... | CWE-131 | 88 |
bool RequestParser::OnHeadersEnd() {
bool matched = view_matcher_(request_->method(), request_->url().path(),
&stream_);
if (!matched) {
LOG_WARN("No view matches the request: %s %s", request_->method().c_str(),
request_->url().path().c_str());
}
return matched;... | CWE-22 | 2 |
static int64_t HHVM_FUNCTION(bccomp, const String& left, const String& right,
int64_t scale /* = -1 */) {
if (scale < 0) scale = BCG(bc_precision);
bc_num first, second;
bc_init_num(&first);
bc_init_num(&second);
bc_str2num(&first, (char*)left.data(), scale);
bc_str2num(&second,... | CWE-190 | 19 |
void CalculateOutputIndexRowSplit(
OpKernelContext* context, const RowPartitionTensor& row_split,
const vector<INDEX_TYPE>& parent_output_index,
INDEX_TYPE output_index_multiplier, INDEX_TYPE output_size,
vector<INDEX_TYPE>* result) {
INDEX_TYPE row_split_size = row_split.size();
if (r... | CWE-131 | 88 |
parse_memory(VALUE klass, VALUE data, VALUE encoding)
{
htmlParserCtxtPtr ctxt;
if (NIL_P(data)) {
rb_raise(rb_eArgError, "data cannot be nil");
}
if (!(int)RSTRING_LEN(data)) {
rb_raise(rb_eRuntimeError, "data cannot be empty");
}
ctxt = htmlCreateMemoryParserCtxt(StringValuePtr(data),
... | CWE-241 | 68 |
static Variant HHVM_FUNCTION(bcpowmod, const String& left, const String& right,
const String& modulus, int64_t scale /* = -1 */) {
if (scale < 0) scale = BCG(bc_precision);
bc_num first, second, mod, result;
bc_init_num(&first);
bc_init_num(&second);
bc_init_num(&mod);
bc_init_n... | CWE-190 | 19 |
TfLiteStatus PrepareHashtableFind(TfLiteContext* context, TfLiteNode* node) {
TF_LITE_ENSURE_EQ(context, NumInputs(node), 3);
TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
const TfLiteTensor* input_resource_id_tensor =
GetInput(context, node, kInputResourceIdTensor);
TF_LITE_ENSURE_EQ(context, input_r... | CWE-125 | 47 |
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
const TfLiteTensor* input_tensor = GetInput(context, node, 0);
const TfLiteTensor* padding_matrix = GetInput(context, node, 1);
TfLiteTensor* output_tensor = GetOutput(context, node, 0);
TF_LITE_ENSURE_EQ(context, NumDimensions(padding_matrix), 2... | CWE-787 | 24 |
void writeStats(Array& /*ret*/) override {
fprintf(stderr, "writeStats start\n");
// RetSame: the return value is the same instance every time
// HasThis: call has a this argument
// AllSame: all returns were the same data even though args are different
// MemberCount: number of different arg sets... | CWE-190 | 19 |
TfLiteRegistration GetPassthroughOpRegistration() {
TfLiteRegistration reg = {nullptr, nullptr, nullptr, nullptr};
reg.init = [](TfLiteContext* context, const char*, size_t) -> void* {
auto* first_new_tensor = new int;
context->AddTensors(context, 2, first_new_tensor);
return first_new_tensor;
};
re... | CWE-125 | 47 |
TfLiteStatus MockCustom::Invoke(TfLiteContext* context, TfLiteNode* node) {
const TfLiteTensor* input = tflite::GetInput(context, node, 0);
const int32_t* input_data = input->data.i32;
const TfLiteTensor* weight = tflite::GetInput(context, node, 1);
const uint8_t* weight_data = weight->data.uint8;
TfLiteTenso... | CWE-787 | 24 |
R_API RBinJavaAnnotation *r_bin_java_annotation_new(ut8 *buffer, ut64 sz, ut64 buf_offset) {
ut32 i = 0;
RBinJavaAnnotation *annotation = NULL;
RBinJavaElementValuePair *evps = NULL;
ut64 offset = 0;
annotation = R_NEW0 (RBinJavaAnnotation);
if (!annotation) {
return NULL;
}
// (ut16) read and set annotation_... | CWE-805 | 63 |
int64_t OpLevelCostEstimator::CalculateOutputSize(const OpInfo& op_info,
bool* found_unknown_shapes) {
int64_t total_output_size = 0;
// Use float as default for calculations.
for (const auto& output : op_info.outputs()) {
DataType dt = output.dtype();
con... | CWE-190 | 19 |
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
auto* params =
reinterpret_cast<TfLiteDepthToSpaceParams*>(node->builtin_data);
TF_LITE_ENSURE_EQ(context, NumInputs(node), 1);
TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
const TfLiteTensor* input = GetInput(context, node, kInputTens... | CWE-125 | 47 |
TypedValue HHVM_FUNCTION(substr_compare,
const String& main_str,
const String& str,
int offset,
int length /* = INT_MAX */,
bool case_insensitivity /* = false */) {
int s1_len = main_str.size()... | CWE-125 | 47 |
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
const TfLitePackParams* data =
reinterpret_cast<TfLitePackParams*>(node->builtin_data);
TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
switch (output->type) {
case kTfLiteFloat32: {
return PackImpl<float>(context, node... | CWE-125 | 47 |
TfLiteStatus SimpleStatefulOp::Invoke(TfLiteContext* context,
TfLiteNode* node) {
OpData* data = reinterpret_cast<OpData*>(node->user_data);
*data->invoke_count += 1;
const TfLiteTensor* input = GetInput(context, node, kInputTensor);
const uint8_t* input_data = GetTensorDa... | CWE-787 | 24 |
void gen_SEK() {
vector<char> errMsg(1024, 0);
int err_status = 0;
vector <uint8_t> encrypted_SEK(1024, 0);
uint32_t enc_len = 0;
SAFE_CHAR_BUF(SEK, 65);
spdlog::info("Generating backup key. Will be stored in backup_key.txt ... ");
sgx_status_t status = trustedGenerateSEK(eid, &err_status... | CWE-787 | 24 |
def test_put
uri = URI('http://localhost:6470/makeme')
req = Net::HTTP::Put.new(uri)
# Set the headers the way we want them.
req['Accept-Encoding'] = '*'
req['Accept'] = 'application/json'
req['User-Agent'] = 'Ruby'
req.body = 'hello'
res = Net::HTTP.start(uri.hostname, uri.port) ... | CWE-444 | 41 |
it "handles Symbol keys with underscore" do
cl = subject.build_command_line("true", :abc_def => "ghi")
expect(cl).to eq "true --abc-def ghi"
end | CWE-78 | 6 |
def read_lines(path, selector)
if selector
IO.foreach(path).select.with_index(1, &selector)
else
URI.open(path, &:read)
end
end | CWE-78 | 6 |
def update_auth
Log.add_info(request, params.inspect)
return unless request.post?
auth = nil
if params[:check_auth_all] == '1'
auth = User::AUTH_ALL
else
auth_selected = params[:auth_selected]
unless auth_selected.nil? or auth_selected.empty?
auth = '|' + auth_sele... | CWE-89 | 0 |
def query
Log.add_info(request, '') # Not to show passwords.
unless @login_user.admin?(User::AUTH_ZEPTAIR)
render(:text => 'ERROR:' + t('msg.need_to_be_admin'))
return
end
target_user = nil
user_id = params[:user_id]
zeptair_id = params[:zeptair_id]
group_id = params[:grou... | CWE-89 | 0 |
it "returns the group permissions for everyone group too" do
category.set_permissions(everyone: :readonly)
category.save!
json = described_class.new(category, scope: Guardian.new(admin), root: false).as_json
expect(json[:group_permissions]).to eq([
{ permission_type: Ca... | CWE-276 | 45 |
def actions
if params[:media_action] != 'crop_url'
authorize! :manage, :media
end
params[:folder] = params[:folder].gsub("//", "/") if params[:folder].present?
case params[:media_action]
when "new_folder"
params[:folder] = slugify_folder(params[:folder])
render partial: "re... | CWE-918 | 16 |
def build_gem_lines(conservative_versioning)
@deps.map do |d|
name = d.name.dump
requirement = if conservative_versioning
", \"#{conservative_version(@definition.specs[d.name][0])}\""
else
", #{d.requirement.as_list.map(&:dump).join(", ")}"
end
if ... | CWE-88 | 3 |
it "downloads a file" do
expect(subject.download(uri).file.read).to eq file
end | CWE-918 | 16 |
def read_lines(filename, selector)
if selector
IO.foreach(filename).select.with_index(1, &selector)
else
URI.open(filename, &:read)
end
end | CWE-78 | 6 |
def RelaxNG string_or_io
RelaxNG.new(string_or_io)
end | CWE-611 | 13 |
def edit_page
# Saved contents of Login User
begin
@research = Research.where("user_id=#{@login_user.id}").first
rescue
end
if @research.nil?
@research = Research.new
else
# Already accepted?
if !@research.status.nil? and @research.status != 0
render(:action =>... | CWE-89 | 0 |
def empty
Log.add_info(request, params.inspect)
@folder_id = params[:id]
mail_account_id = params[:mail_account_id]
SqlHelper.validate_token([mail_account_id])
trash_folder = MailFolder.get_for(@login_user, mail_account_id, MailFolder::XTYPE_TRASH)
mail_folder = MailFolder.find(@folder_id)
... | CWE-89 | 0 |
def self.get_for_group(group_id, incl_img_content=false)
SqlHelper.validate_token([group_id])
if group_id.nil?
office_map = nil
else
if incl_img_content
office_map = OfficeMap.where("group_id=#{group_id}").first
else
sql = 'select id, group_id, img_enabled, img_name, im... | CWE-89 | 0 |
def destroy
Log.add_info(request, params.inspect)
begin
OfficialTitle.destroy(params[:id])
rescue => evar
Log.add_error(nil, evar)
end
@group_id = params[:group_id]
if @group_id.nil? or @group_id.empty?
@group_id = '0' # '0' for ROOT
end
render(:partial => 'grou... | CWE-89 | 0 |
def self.get_for(mail_account_id, enabled=nil, trigger=nil)
return [] if mail_account_id.nil?
SqlHelper.validate_token([mail_account_id, trigger])
con = []
con << "(mail_account_id=#{mail_account_id})"
con << "(enabled=#{(enabled)?(1):(0)})" unless enabled.nil?
con << SqlHelper.get_sql_like... | CWE-89 | 0 |
def get_mail_attachments
Log.add_info(request, params.inspect)
email_id = params[:id]
email = Email.find_by_id(email_id)
if email.nil? or email.user_id != @login_user.id
render(:text => '')
return
end
download_name = "mail_attachments#{email.id}.zip"
zip_file = email.zip_att... | CWE-89 | 0 |
def new
Log.add_info(request, params.inspect)
mail_account_id = params[:mail_account_id]
if mail_account_id.nil? or mail_account_id.empty?
account_xtype = params[:mail_account_xtype]
@mail_account = MailAccount.get_default_for(@login_user.id, account_xtype)
else
@mail_account = Mai... | CWE-89 | 0 |
def attachments_without_content
return [] if self.id.nil?
sql = 'select id, title, memo, name, size, content_type, comment_id, xorder, location from attachments'
sql << ' where comment_id=' + self.id.to_s
sql << ' order by xorder ASC'
begin
attachments = Attachment.find_by_sql(sql)
res... | CWE-89 | 0 |
def install_location filename, destination_dir # :nodoc:
raise Gem::Package::PathError.new(filename, destination_dir) if
filename.start_with? '/'
destination_dir = File.realpath destination_dir if
File.respond_to? :realpath
destination_dir = File.expand_path destination_dir
destination =... | CWE-22 | 2 |
def redirect_url
return "/" unless member_login_node
member_login_node.redirect_url || "/"
end | CWE-601 | 11 |
def self.validate_token(tokens, extra_chars=nil)
extra_chars ||= []
regexp = Regexp.new("^\s*[a-zA-Z0-9_.#{extra_chars.join()}]+\s*$")
[tokens].flatten.each do |token|
next if token.blank?
if token.to_s.match(regexp).nil?
raise("[ERROR] SqlHelper.validate_token failed: #{token}")
... | CWE-89 | 0 |
def team_organize
Log.add_info(request, params.inspect)
team_id = params[:team_id]
unless team_id.nil? or team_id.empty?
begin
@team = Team.find(team_id)
rescue
@team = nil
ensure
if @team.nil?
flash[:notice] = t('msg.already_deleted', :name => Team.mod... | CWE-89 | 0 |
def check_owner
return if params[:id].nil? or params[:id].empty? or @login_user.nil?
begin
owner_id = Location.find(params[:id]).user_id
rescue
owner_id = -1
end
if !@login_user.admin?(User::AUTH_LOCATION) and owner_id != @login_user.id
Log.add_check(request, '[check_owner]'+req... | CWE-89 | 0 |
it "should not display completed tasks" do
task_1 = FactoryGirl.create(:task, :user_id => current_user.id, :name => "Your first task", :bucket => "due_asap", :assigned_to => current_user.id)
task_2 = FactoryGirl.create(:task, :user_id => current_user.id, :name => "Completed task", :bucket => "due_asap", :comple... | CWE-89 | 0 |
def self.parse_csv_row(row, book, idxs, user)
imp_id = (idxs[0].nil? or row[idxs[0]].nil?)?(nil):(row[idxs[0]].strip)
SqlHelper.validate_token([imp_id])
unless imp_id.blank?
org_address = Address.find_by_id(imp_id)
end
if org_address.nil?
address = Address.new
else
address ... | CWE-89 | 0 |
def self.get_tmpl_folder
tmpl_folder = Folder.where("folders.name='#{TMPL_ROOT}'").first
if tmpl_folder.nil?
ary = self.setup_tmpl_folder
unless ary.nil? or ary.empty?
tmpl_folder = ary[0]
tmpl_system_folder = ary[1]
tmpl_workflows_folder = ary[2]
tmpl_local_fol... | CWE-89 | 0 |
def week
Log.add_info(request, params.inspect)
date_s = params[:date]
if date_s.nil? or date_s.empty?
@date = Date.today
else
@date = Date.parse(date_s)
end
params[:display] = 'week'
end | CWE-89 | 0 |
def send_password
Log.add_info(request, params.inspect)
mail_addr = params[:thetisBoxEdit]
SqlHelper.validate_token([mail_addr])
begin
users = User.where("email='#{mail_addr}'").to_a
rescue => evar
end
if users.nil? or users.empty?
Log.add_error(request, evar)
flash[:no... | CWE-89 | 0 |
def call(env)
return @app.call(env) unless env['PATH_INFO'].start_with? "#{@bus.base_route}message-bus/_diagnostics"
route = env['PATH_INFO'].split("#{@bus.base_route}message-bus/_diagnostics")[1]
if @bus.is_admin_lookup.nil? || !@bus.is_admin_lookup.call(env)
return [403, {}, ['not allowed']]
... | CWE-22 | 2 |
it "should find a user by first name and last name" do
@cur_user.stub(:pref).and_return(:activity_user => 'Billy Elliot')
controller.instance_variable_set(:@current_user, @cur_user)
User.should_receive(:where).with("(upper(first_name) LIKE upper('%Billy%') AND upper(last_name) LIKE upper('%Elliot%... | CWE-89 | 0 |
def ajax_delete_mails
Log.add_info(request, params.inspect)
folder_id = params[:id]
mail_account_id = params[:mail_account_id]
unless params[:check_mail].blank?
mail_folder = MailFolder.find(folder_id)
trash_folder = MailFolder.get_for(@login_user, mail_account_id, MailFolder::XTYPE_TRAS... | CWE-89 | 0 |
it "allows/disable marshalling" do
store = Redis::Store::Factory.create :marshalling => false
store.instance_variable_get(:@marshalling).must_equal(false)
store.instance_variable_get(:@options)[:raw].must_equal(true)
end | CWE-502 | 15 |
def self.get_tmpl_subfolder(name)
SqlHelper.validate_token([name])
tmpl_folder = Folder.where("folders.name='#{TMPL_ROOT}'").first
unless tmpl_folder.nil?
con = "(parent_id=#{tmpl_folder.id}) and (name='#{name}')"
begin
child = Folder.where(con).first
rescue => evar
Lo... | CWE-89 | 0 |
def apply(operations)
operations.inject(self) do |builder, (name, argument)|
if argument == true || argument == nil
builder.send(name)
elsif argument.is_a?(Array)
builder.send(name, *argument)
elsif argument.is_a?(Hash)
builder.send(name, **argument)
... | CWE-78 | 6 |
def check_owner
return if (params[:id].nil? or params[:id].empty? or @login_user.nil?)
mail_filter = MailFilter.find(params[:id])
if !@login_user.admin?(User::AUTH_MAIL) and mail_filter.mail_account.user_id != @login_user.id
Log.add_check(request, '[check_owner]'+request.to_s)
flash[:notic... | CWE-89 | 0 |
def login
Log.add_info(request, '') # Not to show passwords.
user = User.authenticate(params[:user])
if user.nil?
flash[:notice] = '<span class=\'font_msg_bold\'>'+t('user.u_name')+'</span>'+t('msg.or')+'<span class=\'font_msg_bold\'>'+t('password.name')+'</span>'+t('msg.is_invalid')
if ... | CWE-89 | 0 |
def destroy_workflow
Log.add_info(request, params.inspect)
Item.find(params[:id]).destroy
@tmpl_folder, @tmpl_workflows_folder = TemplatesHelper.get_tmpl_subfolder(TemplatesHelper::TMPL_WORKFLOWS)
@group_id = params[:group_id]
if @group_id.nil? or @group_id.empty?
@group_id = '0' # '0'... | CWE-89 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.