sqlshield 0.0.3__py3-none-any.whl → 0.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sqlshield might be problematic. Click here for more details.
- sqlshield/models.py +4 -2
- sqlshield/shield.py +6 -2
- {sqlshield-0.0.3.dist-info → sqlshield-0.0.4.dist-info}/METADATA +1 -1
- sqlshield-0.0.4.dist-info/RECORD +8 -0
- {sqlshield-0.0.3.dist-info → sqlshield-0.0.4.dist-info}/WHEEL +1 -1
- sqlshield-0.0.3.dist-info/RECORD +0 -8
- {sqlshield-0.0.3.dist-info → sqlshield-0.0.4.dist-info}/LICENSE +0 -0
- {sqlshield-0.0.3.dist-info → sqlshield-0.0.4.dist-info}/top_level.txt +0 -0
sqlshield/models.py
CHANGED
|
@@ -58,13 +58,15 @@ class MTable(Table):
|
|
|
58
58
|
result.append("%s as %s" % (col.name, col.pub_name))
|
|
59
59
|
return ', '.join(result)
|
|
60
60
|
|
|
61
|
-
def get_alias_sql(self, params):
|
|
61
|
+
def get_alias_sql(self, params, alias=None):
|
|
62
62
|
filterSQL = ''
|
|
63
63
|
if self.filters:
|
|
64
64
|
filterSQL = self.filters.format(**params)
|
|
65
65
|
sql_template = '(select %s from %s %s) as %s'
|
|
66
66
|
colsql = self._get_projections_sql()
|
|
67
|
-
|
|
67
|
+
if alias == None:
|
|
68
|
+
alias = self.pub_name
|
|
69
|
+
query = sql_template % (colsql, self.name, filterSQL, alias)
|
|
68
70
|
return query
|
|
69
71
|
|
|
70
72
|
def generate_schema(self):
|
sqlshield/shield.py
CHANGED
|
@@ -28,12 +28,16 @@ class Session():
|
|
|
28
28
|
|
|
29
29
|
def transformer(node):
|
|
30
30
|
if isinstance(node, exp.Table):
|
|
31
|
-
tbl_name_c = node.this.this
|
|
31
|
+
tbl_name_c = node.this.this
|
|
32
32
|
tbl_name = tbl_name_c.lower()
|
|
33
33
|
if tbl_name not in tbl_map:
|
|
34
34
|
raise Exception('No such table found.', tbl_name_c)
|
|
35
35
|
mtable = tbl_map[tbl_name]
|
|
36
|
-
|
|
36
|
+
if node.alias == '':
|
|
37
|
+
alias = None
|
|
38
|
+
else:
|
|
39
|
+
alias = node.alias
|
|
40
|
+
msql = mtable.get_alias_sql(self.params, alias)
|
|
37
41
|
return parse_one(msql)
|
|
38
42
|
return node
|
|
39
43
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sqlshield
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4
|
|
4
4
|
Summary: A Shield for your LLM generated SQL Queries. It provides an application level control for securing the database from SQL generated by LLM.
|
|
5
5
|
Author-email: Sandeep Giri <sandeepgiri@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/terno-ai/llm-sql-shield
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
sqlshield/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
sqlshield/models.py,sha256=F8lXhJ5hgPDIVinPCRHLYj0TR-hxhI5rss_ETtVBLkQ,4080
|
|
3
|
+
sqlshield/shield.py,sha256=7kXgjkzWpTSsLvn1asq_nNGVp2resPFz2C2S9lder64,1557
|
|
4
|
+
sqlshield-0.0.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
5
|
+
sqlshield-0.0.4.dist-info/METADATA,sha256=b76Xa9a4kJncXgy1IHXC3J7d_-0R3n9Z2LVA0PsQa9g,9313
|
|
6
|
+
sqlshield-0.0.4.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
|
7
|
+
sqlshield-0.0.4.dist-info/top_level.txt,sha256=sMIFlsz4TsFN2Y4jGG_bNkgSeRopF0t0iBSjbFfgIMs,10
|
|
8
|
+
sqlshield-0.0.4.dist-info/RECORD,,
|
sqlshield-0.0.3.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
sqlshield/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
sqlshield/models.py,sha256=Xa9-KeUPHVlfNmMisGkSAMoYp7c4sKfKGK8hnau1GLM,4016
|
|
3
|
-
sqlshield/shield.py,sha256=H-MsM6tHjEJb1QszvPgCUwtA7QqDwFmD9FsZ6jHoAtc,1399
|
|
4
|
-
sqlshield-0.0.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
5
|
-
sqlshield-0.0.3.dist-info/METADATA,sha256=-BS_i0ZyMkzOrVR8oa0933tUMRCscB6WuLwnBuAYrL0,9313
|
|
6
|
-
sqlshield-0.0.3.dist-info/WHEEL,sha256=Wyh-_nZ0DJYolHNn1_hMa4lM7uDedD_RGVwbmTjyItk,91
|
|
7
|
-
sqlshield-0.0.3.dist-info/top_level.txt,sha256=sMIFlsz4TsFN2Y4jGG_bNkgSeRopF0t0iBSjbFfgIMs,10
|
|
8
|
-
sqlshield-0.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|