<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[XSS &amp; SQL Injection?]]></title><description><![CDATA[<p dir="auto">Do you filter parameter inputs from this or do we need to do this in code?</p>
]]></description><link>https://community.appdrag.com/topic/243/xss-sql-injection</link><generator>RSS for Node</generator><lastBuildDate>Wed, 10 Jun 2026 18:49:19 GMT</lastBuildDate><atom:link href="https://community.appdrag.com/topic/243.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 17 Jul 2020 12:46:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to XSS &amp; SQL Injection? on Sun, 19 Jul 2020 08:22:25 GMT]]></title><description><![CDATA[<p dir="auto">I'd like to share another method which is less error prone :</p>
<pre><code>function escapeSQL(strings, ...vars) {
    return vars.reduce((str, v, i) =&gt; {
        if (typeof(v) == 'string') {
            return str + v.replace(/'/g, "''") + strings[i+1];
        } else {
            return str + v + strings[i+1];
        }
    }, strings[0]);
}
var myParam = event.POST.myParam;
var myParam2 = event.POST.myParam2;
var query = escapeSQL`SELECT * FROM MyTable WHERE myColumn='${myParam }' AND mySecondColumn='${myParam2 }'`
</code></pre>
<p dir="auto">This way your query won't be extra long as you don't have to call a function for each parameter</p>
]]></description><link>https://community.appdrag.com/post/864</link><guid isPermaLink="true">https://community.appdrag.com/post/864</guid><dc:creator><![CDATA[Wassim]]></dc:creator><pubDate>Sun, 19 Jul 2020 08:22:25 GMT</pubDate></item><item><title><![CDATA[Reply to XSS &amp; SQL Injection? on Sun, 19 Jul 2020 06:06:07 GMT]]></title><description><![CDATA[<p dir="auto">We do protect for SQL Injection the Visual SQL endpoints, but for real languages (Node.js, C#, Java, Python, ...)<br />
since it's your own code you have to do it by yourself of use a library ...</p>
<p dir="auto">In node.js here is how you can protect a parameter from SQL Injection:</p>
<p dir="auto">You need this function</p>
<pre><code>function Clean(txt){
     if ( txt == null) {  return "";  }
     else{
          return txt.replace(/\'/g, "''");
     }
}
</code></pre>
<p dir="auto">Then you can call it like this:</p>
<pre><code>var myParam = event.POST.myParam;
var SQL = "SELECT * FROM MyTable WHERE myColumn = '" + Clean(MyParam) + "'";
</code></pre>
<p dir="auto">Here is another equivalent syntax with brackets &amp; backticks:</p>
<pre><code>var myParam = event.POST.myParam;
var SQL = `SELECT * FROM MyTable WHERE myColumn = '${Clean(MyParam)}'`;
</code></pre>
]]></description><link>https://community.appdrag.com/post/859</link><guid isPermaLink="true">https://community.appdrag.com/post/859</guid><dc:creator><![CDATA[Joseph Benguira]]></dc:creator><pubDate>Sun, 19 Jul 2020 06:06:07 GMT</pubDate></item><item><title><![CDATA[Reply to XSS &amp; SQL Injection? on Sat, 18 Jul 2020 11:45:22 GMT]]></title><description><![CDATA[<p dir="auto">FWIW, from what i've seen, there is no protection against SQL injection in the input you receive, it's raw from the sender.</p>
<p dir="auto">Not sure about XSS/CORS settings.</p>
]]></description><link>https://community.appdrag.com/post/854</link><guid isPermaLink="true">https://community.appdrag.com/post/854</guid><dc:creator><![CDATA[Daniel Mulroy]]></dc:creator><pubDate>Sat, 18 Jul 2020 11:45:22 GMT</pubDate></item></channel></rss>