<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">"use strict";(self.webpackChunkdoc=self.webpackChunkdoc||[]).push([[4148],{3905:(e,t,a)=&gt;{a.d(t,{Zo:()=&gt;c,kt:()=&gt;m});var n=a(7294);function r(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function i(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&amp;&amp;(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function l(e){for(var t=1;t&lt;arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?i(Object(a),!0).forEach((function(t){r(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):i(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function o(e,t){if(null==e)return{};var a,n,r=function(e,t){if(null==e)return{};var a,n,r={},i=Object.keys(e);for(n=0;n&lt;i.length;n++)a=i[n],t.indexOf(a)&gt;=0||(r[a]=e[a]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n&lt;i.length;n++)a=i[n],t.indexOf(a)&gt;=0||Object.prototype.propertyIsEnumerable.call(e,a)&amp;&amp;(r[a]=e[a])}return r}var s=n.createContext({}),p=function(e){var t=n.useContext(s),a=t;return e&amp;&amp;(a="function"==typeof e?e(t):l(l({},t),e)),a},c=function(e){var t=p(e.components);return n.createElement(s.Provider,{value:t},e.children)},u={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},d=n.forwardRef((function(e,t){var a=e.components,r=e.mdxType,i=e.originalType,s=e.parentName,c=o(e,["components","mdxType","originalType","parentName"]),d=p(a),m=r,k=d["".concat(s,".").concat(m)]||d[m]||u[m]||i;return a?n.createElement(k,l(l({ref:t},c),{},{components:a})):n.createElement(k,l({ref:t},c))}));function m(e,t){var a=arguments,r=t&amp;&amp;t.mdxType;if("string"==typeof e||r){var i=a.length,l=new Array(i);l[0]=d;var o={};for(var s in t)hasOwnProperty.call(t,s)&amp;&amp;(o[s]=t[s]);o.originalType=e,o.mdxType="string"==typeof e?e:r,l[1]=o;for(var p=2;p&lt;i;p++)l[p]=a[p];return n.createElement.apply(null,l)}return n.createElement.apply(null,a)}d.displayName="MDXCreateElement"},597:(e,t,a)=&gt;{a.r(t),a.d(t,{assets:()=&gt;s,contentTitle:()=&gt;l,default:()=&gt;u,frontMatter:()=&gt;i,metadata:()=&gt;o,toc:()=&gt;p});var n=a(7462),r=(a(7294),a(3905));const i={},l="Dynamic Data Masking",o={unversionedId:"data-privacy/data-masking",id:"data-privacy/data-masking",title:"Dynamic Data Masking",description:"Dynamic Data Masking is a Column-level Security feature that uses masking tag to selectively mask plain-text data in a query result set. It can be used to hide sensitive data in the result set of a query over designated fields, while the data in the database is not changed.",source:"@site/docs/data-privacy/data-masking.mdx",sourceDirName:"data-privacy",slug:"/data-privacy/data-masking",permalink:"/docs/data-privacy/data-masking",draft:!1,editUrl:"https://github.com/Canner/vulcan-sql/tree/main/packages/doc/docs/data-privacy/data-masking.mdx",tags:[],version:"current",frontMatter:{},sidebar:"tutorialSidebar",previous:{title:"Authorization",permalink:"/docs/data-privacy/authz"},next:{title:"Column Level Security",permalink:"/docs/data-privacy/cls"}},s={},p=[{value:"Using &lt;code&gt;masking&lt;/code&gt; tag",id:"using-masking-tag",level:2},{value:"Masking Data With &lt;code&gt;partial&lt;/code&gt; Function",id:"masking-data-with-partial-function",level:2}],c={toc:p};function u(e){let{components:t,...a}=e;return(0,r.kt)("wrapper",(0,n.Z)({},c,a,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h1",{id:"dynamic-data-masking"},"Dynamic Data Masking"),(0,r.kt)("p",null,"Dynamic Data Masking is a ",(0,r.kt)("a",{parentName:"p",href:"./cls"},"Column-level Security")," feature that uses ",(0,r.kt)("inlineCode",{parentName:"p"},"masking")," tag to selectively mask plain-text data in a query result set. It can be used to hide sensitive data in the result set of a query over designated fields, while the data in the database is not changed."),(0,r.kt)("h2",{id:"using-masking-tag"},"Using ",(0,r.kt)("inlineCode",{parentName:"h2"},"masking")," tag"),(0,r.kt)("p",null,"You can use the ",(0,r.kt)("inlineCode",{parentName:"p"},"masking")," tag with ",(0,r.kt)("inlineCode",{parentName:"p"},"{% ... %}"),"."),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sql"},"{% masking &lt;column-name&gt; &lt;masking-function&gt; %}\n")),(0,r.kt)("p",null,"  Where:"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"&lt;column-name&gt;")," is the name of the column to mask."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"&lt;masking-function&gt;")," is the masking function to use. Currently, VulcanSQL supports ",(0,r.kt)("inlineCode",{parentName:"li"},"partial")," masking function.")),(0,r.kt)("h2",{id:"masking-data-with-partial-function"},"Masking Data With ",(0,r.kt)("inlineCode",{parentName:"h2"},"partial")," Function"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-js"},"partial(prefixTotal, padding, suffixTotal);\n")),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"prefixTotal")," is the number of characters to display at the beginning of the string."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"padding")," is the custom string to use for masking."),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("inlineCode",{parentName:"li"},"suffixTotal")," is the number of characters to display at the end of the string.")),(0,r.kt)("p",null,"Here is an example of how to use the ",(0,r.kt)("inlineCode",{parentName:"p"},"partial")," function with the ",(0,r.kt)("inlineCode",{parentName:"p"},"masking")," tag. Assuming we have a ",(0,r.kt)("inlineCode",{parentName:"p"},"users")," table with an ",(0,r.kt)("inlineCode",{parentName:"p"},"id")," column, and we want to partially mask the first two and last two characters of each ",(0,r.kt)("inlineCode",{parentName:"p"},"id")," value:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-sql"},"SELECT\n  {% masking id partial(2, 'xxxxxxx', 2) %} as id,\n  name\nFROM users;\n")),(0,r.kt)("p",null,"This will return a result where the first two and last two characters of each ",(0,r.kt)("inlineCode",{parentName:"p"},"id")," value are replaced with ",(0,r.kt)("inlineCode",{parentName:"p"},"x"),":"),(0,r.kt)("table",null,(0,r.kt)("thead",{parentName:"table"},(0,r.kt)("tr",{parentName:"thead"},(0,r.kt)("th",{parentName:"tr",align:null},"id"),(0,r.kt)("th",{parentName:"tr",align:null},"name"))),(0,r.kt)("tbody",{parentName:"table"},(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},"ABxxxxxxxCD"),(0,r.kt)("td",{parentName:"tr",align:null},"Ivan")),(0,r.kt)("tr",{parentName:"tbody"},(0,r.kt)("td",{parentName:"tr",align:null},"EFxxxxxxxGH"),(0,r.kt)("td",{parentName:"tr",align:null},"William")))))}u.isMDXComponent=!0}}]);</pre></body></html>