Simple and safe SQL queries with C plus plus templates

被引:9
|
作者
Gil, Joseph [1 ]
Lenz, Keren [1 ]
机构
[1] Technion Israel Inst Technol, Dept Comp Sci, IL-32000 Haifa, Israel
关键词
C plus; Template programming; Embedded languages; Domain specific languages; Databases; Structural type equivalence; Relational algebra; CHECKING;
D O I
10.1016/j.scico.2010.01.004
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Most large software applications rely on an external relational database for storing and managing persistent data. Typically, such applications interact with the database by first constructing strings that represent SQL statements, and then submitting these for execution by the database engine. The fact that these statements are only checked for correctness at runtime is a source for many potential defects, including type and syntax errors and vulnerability to injection attacks. The ARARAT system presented here offers a method for dealing with these difficulties by coercing the host C++ compiler to do the necessary checks of the generated strings. A library of templates and preprocessor directives is used to embed in C++ a little language representing an augmented relational algebra formalism. Type checking of this embedded language, carried out by our template library, assures, at compile-time, the correctness and safety of the generated SQL strings. All SQL statements constructed by ARARAT are guaranteed to be syntactically correct, and type safe with respect to the database schema. Moreover, ARARAT statically ensures that the generated statements are immune to all injection attacks. The standard techniques of "expression templates" and "compile-time symbolic derivation" for compile-time representation of symbolic structures, are enhanced in our system. We demonstrate the support of a type system and a symbol table lookup of the symbolic structure. A key observation of this work is that type equivalence of instantiated nominally typed generics in C++ (as well as other languages, e.g., JAVA) is structural rather than nominal. This makes it possible to embed the structural type system, characteristic to persistent data management, in the nominal type system of C++. For some of its advanced features, ARARAT relies on two small extensions to the standard C++ language: the typeof pseudo operator and the _COUNTER_ preprocessor macro. (C) 2010 Elsevier B.V. All rights reserved.
引用
收藏
页码:573 / 595
页数:23
相关论文
共 50 条
  • [1] Static Integration of SQL Queries in C plus plus Programs
    Sysak, Maciej
    Zielinski, Bartosz
    Kruszynski, Piotr
    Sobieski, Scibor
    Maslanka, Pawel
    [J]. ADVANCES IN DATABASES AND INFORMATION SYSTEMS (ADBIS 2014), 2014, 8716 : 126 - 138
  • [2] Variadic Templates for C plus
    Gregor, Douglas
    Jaervi, Jaakko
    [J]. APPLIED COMPUTING 2007, VOL 1 AND 2, 2007, : 1101 - +
  • [3] Translating Lambda Calculus into C plus plus Templates
    Sefl, Vit
    [J]. TRENDS IN FUNCTIONAL PROGRAMMING (TFP 2021), 2021, 12834 : 95 - 115
  • [4] Early Detection of Type Errors in C plus plus Templates
    Chen, Sheng
    Erwig, Martin
    [J]. PEPM '14: PROCEEDINGS OF THE ACM SIGPLAN WORKSHOP ON PARTIAL EVALUATION AND PROGRAM MANIPULATION, 2014, : 133 - 144
  • [5] Employing C plus plus Templates in the Design of a Computer Algebra Library
    Brandt, Alexander
    Moir, Robert H. C.
    Maza, Marc Moreno
    [J]. MATHEMATICAL SOFTWARE - ICMS 2020, 2020, 12097 : 342 - 352
  • [6] Automatically Preparing Safe SQL Queries
    Bisht, Prithvi
    Sistla, A. Prasad
    Venkatakrishnan, V. N.
    [J]. FINANCIAL CRYPTOGRAPHY AND DATA SECURITY, 2010, 6052 : 272 - 288
  • [7] Ironclad C plus plus A Library-Augmented Type-Safe Subset of C plus
    DeLozier, Christian
    Eisenberg, Richard
    Nagarakatte, Santosh
    Osera, Peter-Michael
    Martin, Milo M. K.
    Zdancewic, Steve
    [J]. ACM SIGPLAN NOTICES, 2013, 48 (10) : 287 - 304
  • [8] Automatic Offloading C plus plus Expression Templates to CUDA Enabled GPUs
    Chen, Jie
    Joo, Balint
    Watson, William, III
    Edwards, Robert
    [J]. 2012 IEEE 26TH INTERNATIONAL PARALLEL AND DISTRIBUTED PROCESSING SYMPOSIUM WORKSHOPS & PHD FORUM (IPDPSW), 2012, : 2359 - 2368
  • [9] Neat SIMD Elegant Vectorization in C plus plus by using Specialized Templates
    Gross, Matthias
    [J]. 2016 INTERNATIONAL CONFERENCE ON HIGH PERFORMANCE COMPUTING & SIMULATION (HPCS 2016), 2016, : 848 - 857
  • [10] TAPS: Automatically Preparing Safe SQL Queries
    Bisht, Prithvi
    Sistla, A. Prasad
    Venkatakrishnan, V. N.
    [J]. PROCEEDINGS OF THE 17TH ACM CONFERENCE ON COMPUTER AND COMMUNICATIONS SECURITY (CCS'10), 2010, : 645 - 647