Skip to content

Commit 93a1030

Browse files
committed
0.1
1 parent 547a1e5 commit 93a1030

File tree

1 file changed

+60
-37
lines changed

1 file changed

+60
-37
lines changed

magento_appsec_file_check.php

+60-37
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,47 @@
1313
//
1414
$_securityNotices=array(
1515
'APPSEC-1034, addressing bypassing custom admin URL' => array(
16-
'grep' => array(
17-
'grep -irl "<use>admin</use>"'. ' '. $_magentoPath. 'app/code/*'
16+
'text' => '',
17+
'exec' => array(
18+
'path' => array(
19+
$_magentoPath. 'app/code/*'
20+
),
21+
'cmd' => 'grep -irl ' ,
22+
'query' => array(
23+
'"<use>admin</use>"'
24+
)
1825
),
1926
'magentopath' => $_magentoPath),
2027
'APPSEC-1063, addressing possible SQL injection' => array(
21-
'grep' => array(
22-
'grep -irl "collection->addFieldToFilter(\'"'. ' '. $_magentoPath. 'app/code/community/*',
23-
'grep -irl "collection->addFieldToFilter(\'"'. ' '. $_magentoPath. 'app/code/local/*',
24-
'grep -irl "collection->addFieldToFilter(\'\`"'. ' '. $_magentoPath. 'app/code/community/*',
25-
'grep -irl "collection->addFieldToFilter(\'\`"'. ' '. $_magentoPath. 'app/code/local/*'
28+
'text' => '',
29+
'exec' => array(
30+
'path' => array(
31+
$_magentoPath. 'app/code/community/*',
32+
$_magentoPath. 'app/code/local/*'
33+
),
34+
'cmd' => 'grep -irl ' ,
35+
'query' => array(
36+
'"collection->addFieldToFilter(\'"',
37+
'"collection->addFieldToFilter(\'\`"',
38+
)
2639
),
2740
'magentopath' => $_magentoPath),
2841
'APPSEC-1057, template processing method allows access to private information' => array(
29-
'grep' => array(
30-
'grep -irl "{{config path="'. ' '. $_magentoPath. 'app/code/community/*',
31-
'grep -irl "{{config path="'. ' '. $_magentoPath. 'app/code/local/*',
32-
'grep -irl "{{config path="'. ' '. $_magentoPath. 'app/locale/*',
33-
'grep -irl "{{config path="'. ' '. $_magentoPath. 'app/design/frontend/*',
34-
'grep -irl "{{block type="'. ' '. $_magentoPath. 'app/code/community/*',
35-
'grep -irl "{{block type="'. ' '. $_magentoPath. 'app/code/local/*',
36-
'grep -irl "{{block type="'. ' '. $_magentoPath. 'app/locale/*',
37-
'grep -irl "{{block type="'. ' '. $_magentoPath. 'app/design/frontend/*'
42+
'text' => '',
43+
'exec' => array(
44+
'path' => array(
45+
$_magentoPath. 'app/code/community/*',
46+
$_magentoPath. 'app/code/local/*',
47+
$_magentoPath. 'app/locale/*',
48+
$_magentoPath. 'app/design/frontend/*'
49+
),
50+
'cmd' => 'grep -irl ' ,
51+
'query' => array(
52+
'"{{config path="',
53+
'"{{block type="',
54+
)
3855
),
39-
'magentopath' => $_magentoPath)
56+
'magentopath' => $_magentoPath)
4057
);
4158

4259
// EXEC
@@ -59,37 +76,43 @@
5976
function doExec($_securityNotice)
6077
{
6178
$_text='';
79+
$_exec=$_securityNotice['exec']['cmd'];
6280

63-
foreach ($_securityNotice['grep'] as $_grep)
81+
foreach ($_securityNotice['exec']['path'] as $_searchPath)
6482
{
65-
$_exec=$_grep;
83+
6684
$_count=0;
6785
$_search='';
68-
69-
exec($_exec, $_output, $_status);
70-
preg_match('/"([^"]+)"/', $_grep, $_query);
71-
72-
if (1 === $_status)
73-
{
7486

75-
$_text=$_text.$_query[1]. ' not found.'. "\n";
76-
continue;
77-
}
78-
79-
if (0 === $_status)
87+
foreach ($_securityNotice['exec']['query'] as $_searchQuery)
8088
{
81-
$_count=count($_output);
89+
90+
$_text=$_text.'looking in '. $_searchPath. ' for '. $_searchQuery. "\n";
91+
92+
exec($_exec. $_searchQuery. ' '. $_searchPath, $_output, $_status);
8293

83-
foreach ($_output as $_line)
94+
if (1 === $_status)
95+
{
96+
97+
$_text=$_text.$_searchQuery. ' not found.'. "\n";
98+
continue;
99+
}
100+
101+
if (0 === $_status)
84102
{
85-
$_search=$_search.$_query[1]. ' found in '. str_replace($_securityNotice['magentopath'],' ', $_line). "\n";
103+
$_count=count($_output);
104+
105+
foreach ($_output as $_line)
106+
{
107+
$_search=$_search.$_searchQuery. ' found in '. str_replace($_securityNotice['magentopath'],' ', $_line). "\n";
108+
}
109+
110+
} else {
111+
$_text=$_text. 'Command '. $_securityNotice['exec']['cmd']. ' failed with status: ' . $_status. "\n";
86112
}
87113

88-
} else {
89-
$_text=$_text. 'Command '. $_grep. ' failed with status: ' . $_status. "\n";
114+
$_text=$_text.$_count. ' effected files : '. "\n". $_search. "\n";
90115
}
91-
92-
$_text=$_text.$_count. ' effected files : '. "\n". $_search;
93116
}
94117

95118
return $_text;

0 commit comments

Comments
 (0)