Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
Zipr Toolchain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
Zipr Toolchain
Commits
c9448057
Commit
c9448057
authored
10 years ago
by
an7s
Browse files
Options
Downloads
Patches
Plain Diff
Updated tests
Former-commit-id: b22b5caf5438ca20c31734741584155b1fd6c918
parent
3f1267bd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
appfw/tests/postgres/postgres.test.env.sh
+10
-11
10 additions, 11 deletions
appfw/tests/postgres/postgres.test.env.sh
appfw/tests/postgres/testpg2.c
+14
-3
14 additions, 3 deletions
appfw/tests/postgres/testpg2.c
with
24 additions
and
14 deletions
appfw/tests/postgres/postgres.test.env.sh
+
10
−
11
View file @
c9448057
...
...
@@ -95,9 +95,8 @@ if [ ! $? -eq 0 ]; then
fi
# test attack queries
rm
-f
$tmp
APPFW_VERBOSE
=
1
QUERY_DATA
=
"' or 1 = 1;--"
./testpg1.exe.env.peasoup
>
$tmp
2>&1
grep
-i
"
sql injection"
$tmp
|
grep
-i
detected
grep
-i
"
tautology"
$tmp
if
[
!
$?
-eq
0
]
;
then
cat
$tmp
cleanup 4
"False negative detected: attack query for testpg1.exe.env.peasoup should have been detected"
...
...
@@ -105,7 +104,7 @@ fi
rm
-f
$tmp
APPFW_VERBOSE
=
1
QUERY_DATA
=
"' and /* */ 1 = 1 /* */; /*--*/"
./testpg1.exe.env.peasoup
>
$tmp
2>&1
grep
-i
"sql injection"
$tmp
|
grep
-i
detected
grep
-i
"sql injection"
$tmp
if
[
!
$?
-eq
0
]
;
then
cat
$tmp
cleanup 5
"False negative detected: attack query for testpg1.exe.env.peasoup should have been detected"
...
...
@@ -113,7 +112,7 @@ fi
rm
-f
$tmp
APPFW_VERBOSE
=
1
QUERY_DATA
=
"%' or 1 = 1; -- select *"
./testpg1.exe.env.peasoup
>
$tmp
2>&1
grep
-i
"sql injection"
$tmp
|
grep
-i
detected
grep
-i
"sql injection"
$tmp
if
[
!
$?
-eq
0
]
;
then
cat
$tmp
cleanup 6
"False negative detected: attack query for testpg1.exe.env.peasoup should have been detected"
...
...
@@ -125,16 +124,16 @@ fi
# test good queries
rm
-f
$tmp
2>/dev/null
QUERY_DATA
=
"bob"
./testpg2.exe.env.peasoup
>
$tmp
2>&1
grep
-i
query
$tmp
|
grep
-i
success
APPFW_VERBOSE
=
1
QUERY_DATA
=
"bob"
./testpg2.exe.env.peasoup
>
$tmp
2>&1
grep
-i
--binary-files
=
text
query
$tmp
|
grep
-i
success
if
[
!
$?
-eq
0
]
;
then
cat
$tmp
cleanup 7
"False positive detected: query for testpg2.exe.env.peasoup should have succeeded"
fi
rm
-f
$tmp
QUERY_DATA
=
"select * from xyz"
./testpg2.exe.env.peasoup
>
$tmp
2>&1
grep
-i
query
$tmp
|
grep
-i
success
APPFW_VERBOSE
=
1
QUERY_DATA
=
"select * from xyz"
./testpg2.exe.env.peasoup
>
$tmp
2>&1
grep
-i
--binary-files
=
text
query
$tmp
|
grep
-i
success
if
[
!
$?
-eq
0
]
;
then
cat
$tmp
cleanup 8
"False positive detected: query for testpg2.exe.env.peasoup should have succeeded"
...
...
@@ -143,7 +142,7 @@ fi
# test attack queries
rm
-f
$tmp
APPFW_VERBOSE
=
1
QUERY_DATA
=
"' or 1 = 1;--"
./testpg2.exe.env.peasoup
>
$tmp
2>&1
grep
-i
"sql injection"
$tmp
|
grep
-i
detected
grep
-i
"sql injection"
$tmp
if
[
!
$?
-eq
0
]
;
then
cat
$tmp
cleanup 9
"False negative detected: attack query for testpg2.exe.env.peasoup should have been detected"
...
...
@@ -151,7 +150,7 @@ fi
rm
-f
$tmp
APPFW_VERBOSE
=
1
QUERY_DATA
=
"' and /* */ 1 = 1 /* */; /*--*/"
./testpg2.exe.env.peasoup
>
$tmp
2>&1
grep
-i
"sql injection"
$tmp
|
grep
-i
detected
grep
-i
"sql injection"
$tmp
if
[
!
$?
-eq
0
]
;
then
cat
$tmp
cleanup 10
"False negative detected: attack query for testpg2.exe.env.peasoup should have been detected"
...
...
@@ -159,7 +158,7 @@ fi
rm
-f
$tmp
APPFW_VERBOSE
=
1
QUERY_DATA
=
"%' or 1 = 1; -- select *"
./testpg2.exe.env.peasoup
>
$tmp
2>&1
grep
-i
"sql injection"
$tmp
|
grep
-i
detected
grep
-i
"sql injection"
$tmp
if
[
!
$?
-eq
0
]
;
then
cat
$tmp
cleanup 11
"False negative detected: attack query for testpg2.exe.env.peasoup should have been detected"
...
...
This diff is collapsed.
Click to expand it.
appfw/tests/postgres/testpg2.c
+
14
−
3
View file @
c9448057
...
...
@@ -56,9 +56,20 @@ int main(int argc, char *argv[])
return
0
;
}
sprintf
(
query
,
fmtString
,
argv
[
1
]);
result
=
PQexec
(
conn
,
query
);
printf
(
"%s
\n
"
,
query
);
result
=
PQexec
(
conn
,
query
);
if
(
PQresultStatus
(
result
)
==
PGRES_TUPLES_OK
)
{
fprintf
(
stderr
,
"-------------------------------------------
\n
"
);
fprintf
(
stderr
,
"
\t
Query success: %s
\n
"
,
query
);
fprintf
(
stderr
,
"-------------------------------------------
\n
"
);
}
else
{
fprintf
(
stderr
,
"-------------------------------------------
\n
"
);
fprintf
(
stderr
,
"
\t
Query failed: %s
\n
"
,
query
);
fprintf
(
stderr
,
"-------------------------------------------
\n
"
);
}
}
/* output fields 1 and 2 of each row */
int
i
;
for
(
i
=
0
;
i
<
PQntuples
(
result
);
++
i
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment