[Forensics-changes] [yara] 79/135: Raise warning when the deprecated "entrypoint" keyword is used
Hilko Bengen
bengen at moszumanska.debian.org
Sat Jul 1 10:27:34 UTC 2017
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag v3.1.0
in repository yara.
commit 675177966f121da16e6125e5750225ce3b1bf3d6
Author: Victor M. Alvarez <plusvic at gmail.com>
Date: Thu Aug 7 10:32:32 2014 +0200
Raise warning when the deprecated "entrypoint" keyword is used
---
libyara/grammar.c | 61 +++++++++++++++++++++++---------------------
libyara/grammar.y | 3 +++
libyara/include/yara/lexer.h | 5 ++++
libyara/lexer.c | 20 +++++++++++++++
libyara/lexer.l | 20 +++++++++++++++
libyara/parser.c | 12 +--------
6 files changed, 81 insertions(+), 40 deletions(-)
diff --git a/libyara/grammar.c b/libyara/grammar.c
index 7eaa043..4752b0d 100644
--- a/libyara/grammar.c
+++ b/libyara/grammar.c
@@ -640,9 +640,9 @@ static const yytype_uint16 yyrline[] =
1148, 1154, 1160, 1166, 1174, 1183, 1192, 1201, 1210, 1237,
1264, 1291, 1295, 1303, 1304, 1309, 1331, 1343, 1359, 1358,
1364, 1373, 1374, 1379, 1384, 1393, 1394, 1398, 1406, 1410,
- 1419, 1428, 1439, 1450, 1461, 1472, 1483, 1494, 1503, 1526,
- 1539, 1552, 1572, 1607, 1616, 1625, 1634, 1643, 1652, 1661,
- 1670, 1679, 1687, 1696, 1705
+ 1419, 1431, 1442, 1453, 1464, 1475, 1486, 1497, 1506, 1529,
+ 1542, 1555, 1575, 1610, 1619, 1628, 1637, 1646, 1655, 1664,
+ 1673, 1682, 1690, 1699, 1708
};
#endif
@@ -3143,6 +3143,9 @@ yyreduce:
case 90:
#line 1420 "grammar.y"
{
+ yywarning(yyscanner,
+ "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " "function from PE module instead.");
+
compiler->last_result = yr_parser_emit(
yyscanner, OP_ENTRYPOINT, NULL);
@@ -3153,7 +3156,7 @@ yyreduce:
break;
case 91:
-#line 1429 "grammar.y"
+#line 1432 "grammar.y"
{
CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "int8");
@@ -3167,7 +3170,7 @@ yyreduce:
break;
case 92:
-#line 1440 "grammar.y"
+#line 1443 "grammar.y"
{
CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "int16");
@@ -3181,7 +3184,7 @@ yyreduce:
break;
case 93:
-#line 1451 "grammar.y"
+#line 1454 "grammar.y"
{
CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "int32");
@@ -3195,7 +3198,7 @@ yyreduce:
break;
case 94:
-#line 1462 "grammar.y"
+#line 1465 "grammar.y"
{
CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "uint8");
@@ -3209,7 +3212,7 @@ yyreduce:
break;
case 95:
-#line 1473 "grammar.y"
+#line 1476 "grammar.y"
{
CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "uint16");
@@ -3223,7 +3226,7 @@ yyreduce:
break;
case 96:
-#line 1484 "grammar.y"
+#line 1487 "grammar.y"
{
CHECK_TYPE((yyvsp[(3) - (4)].expression_type), EXPRESSION_TYPE_INTEGER, "uint32");
@@ -3237,7 +3240,7 @@ yyreduce:
break;
case 97:
-#line 1495 "grammar.y"
+#line 1498 "grammar.y"
{
compiler->last_result = yr_parser_emit_with_arg(
yyscanner, OP_PUSH, (yyvsp[(1) - (1)].integer), NULL);
@@ -3249,7 +3252,7 @@ yyreduce:
break;
case 98:
-#line 1504 "grammar.y"
+#line 1507 "grammar.y"
{
SIZED_STRING* sized_string = (yyvsp[(1) - (1)].sized_string);
char* string;
@@ -3275,7 +3278,7 @@ yyreduce:
break;
case 99:
-#line 1527 "grammar.y"
+#line 1530 "grammar.y"
{
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner,
@@ -3291,7 +3294,7 @@ yyreduce:
break;
case 100:
-#line 1540 "grammar.y"
+#line 1543 "grammar.y"
{
compiler->last_result = yr_parser_reduce_string_identifier(
yyscanner,
@@ -3307,7 +3310,7 @@ yyreduce:
break;
case 101:
-#line 1553 "grammar.y"
+#line 1556 "grammar.y"
{
compiler->last_result = yr_parser_emit_with_arg(
yyscanner,
@@ -3330,7 +3333,7 @@ yyreduce:
break;
case 102:
-#line 1573 "grammar.y"
+#line 1576 "grammar.y"
{
if ((yyvsp[(1) - (1)].object) == (YR_OBJECT*) -1) // loop identifier
{
@@ -3368,7 +3371,7 @@ yyreduce:
break;
case 103:
-#line 1608 "grammar.y"
+#line 1611 "grammar.y"
{
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "+");
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "+");
@@ -3380,7 +3383,7 @@ yyreduce:
break;
case 104:
-#line 1617 "grammar.y"
+#line 1620 "grammar.y"
{
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "-");
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "-");
@@ -3392,7 +3395,7 @@ yyreduce:
break;
case 105:
-#line 1626 "grammar.y"
+#line 1629 "grammar.y"
{
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "*");
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "*");
@@ -3404,7 +3407,7 @@ yyreduce:
break;
case 106:
-#line 1635 "grammar.y"
+#line 1638 "grammar.y"
{
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "\\");
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "\\");
@@ -3416,7 +3419,7 @@ yyreduce:
break;
case 107:
-#line 1644 "grammar.y"
+#line 1647 "grammar.y"
{
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "%");
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "%");
@@ -3428,7 +3431,7 @@ yyreduce:
break;
case 108:
-#line 1653 "grammar.y"
+#line 1656 "grammar.y"
{
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^");
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^");
@@ -3440,7 +3443,7 @@ yyreduce:
break;
case 109:
-#line 1662 "grammar.y"
+#line 1665 "grammar.y"
{
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^");
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "^");
@@ -3452,7 +3455,7 @@ yyreduce:
break;
case 110:
-#line 1671 "grammar.y"
+#line 1674 "grammar.y"
{
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "|");
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "|");
@@ -3464,7 +3467,7 @@ yyreduce:
break;
case 111:
-#line 1680 "grammar.y"
+#line 1683 "grammar.y"
{
CHECK_TYPE((yyvsp[(2) - (2)].expression_type), EXPRESSION_TYPE_INTEGER, "~");
@@ -3475,7 +3478,7 @@ yyreduce:
break;
case 112:
-#line 1688 "grammar.y"
+#line 1691 "grammar.y"
{
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<<");
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, "<<");
@@ -3487,7 +3490,7 @@ yyreduce:
break;
case 113:
-#line 1697 "grammar.y"
+#line 1700 "grammar.y"
{
CHECK_TYPE((yyvsp[(1) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">>");
CHECK_TYPE((yyvsp[(3) - (3)].expression_type), EXPRESSION_TYPE_INTEGER, ">>");
@@ -3499,7 +3502,7 @@ yyreduce:
break;
case 114:
-#line 1706 "grammar.y"
+#line 1709 "grammar.y"
{
(yyval.expression_type) = (yyvsp[(1) - (1)].expression_type);
}
@@ -3507,7 +3510,7 @@ yyreduce:
/* Line 1267 of yacc.c. */
-#line 3511 "grammar.c"
+#line 3514 "grammar.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -3721,7 +3724,7 @@ yyreturn:
}
-#line 1711 "grammar.y"
+#line 1714 "grammar.y"
diff --git a/libyara/grammar.y b/libyara/grammar.y
index 50d687f..a2a0d57 100644
--- a/libyara/grammar.y
+++ b/libyara/grammar.y
@@ -1418,6 +1418,9 @@ primary_expression
}
| _ENTRYPOINT_
{
+ yywarning(yyscanner,
+ "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" " "function from PE module instead.");
+
compiler->last_result = yr_parser_emit(
yyscanner, OP_ENTRYPOINT, NULL);
diff --git a/libyara/include/yara/lexer.h b/libyara/include/yara/lexer.h
index 5fabfe5..0c6a5a4 100644
--- a/libyara/include/yara/lexer.h
+++ b/libyara/include/yara/lexer.h
@@ -35,6 +35,7 @@ limitations under the License.
#define yylex yara_yylex
#define yyerror yara_yyerror
#define yyfatal yara_yyfatal
+#define yywarning yara_yywarning
#define yychar yara_yychar
#define yydebug yara_yydebug
#define yynerrs yara_yynerrs
@@ -75,6 +76,10 @@ void yyerror(
YR_COMPILER* compiler,
const char *error_message);
+void yywarning(
+ yyscan_t yyscanner,
+ const char *warning_message);
+
void yyfatal(
yyscan_t yyscanner,
const char *error_message);
diff --git a/libyara/lexer.c b/libyara/lexer.c
index 41967dc..7d3ffc1 100644
--- a/libyara/lexer.c
+++ b/libyara/lexer.c
@@ -2875,6 +2875,26 @@ void yara_yyfree (void * ptr , yyscan_t yyscanner)
+void yywarning(
+ yyscan_t yyscanner,
+ const char *warning_message)
+{
+ YR_COMPILER* compiler = yara_yyget_extra(yyscanner);
+ char* file_name;
+
+ if (compiler->file_name_stack_ptr > 0)
+ file_name = compiler->file_name_stack[compiler->file_name_stack_ptr - 1];
+ else
+ file_name = NULL;
+
+ compiler->error_report_function(
+ YARA_ERROR_LEVEL_WARNING,
+ file_name,
+ yara_yyget_lineno(yyscanner),
+ warning_message);
+}
+
+
void yyfatal(
yyscan_t yyscanner,
const char *error_message)
diff --git a/libyara/lexer.l b/libyara/lexer.l
index ca62816..a25e17d 100644
--- a/libyara/lexer.l
+++ b/libyara/lexer.l
@@ -556,6 +556,26 @@ $({letter}|{digit}|_)* {
%%
+void yywarning(
+ yyscan_t yyscanner,
+ const char *warning_message)
+{
+ YR_COMPILER* compiler = yyget_extra(yyscanner);
+ char* file_name;
+
+ if (compiler->file_name_stack_ptr > 0)
+ file_name = compiler->file_name_stack[compiler->file_name_stack_ptr - 1];
+ else
+ file_name = NULL;
+
+ compiler->error_report_function(
+ YARA_ERROR_LEVEL_WARNING,
+ file_name,
+ yyget_lineno(yyscanner),
+ warning_message);
+}
+
+
void yyfatal(
yyscan_t yyscanner,
const char *error_message)
diff --git a/libyara/parser.c b/libyara/parser.c
index dff6773..dac670b 100644
--- a/libyara/parser.c
+++ b/libyara/parser.c
@@ -439,7 +439,6 @@ YR_STRING* yr_parser_reduce_string_declaration(
int32_t min_gap;
int32_t max_gap;
- char* file_name;
char message[512];
YR_COMPILER* compiler = yyget_extra(yyscanner);
@@ -587,11 +586,6 @@ YR_STRING* yr_parser_reduce_string_declaration(
goto _exit;
}
- if (compiler->file_name_stack_ptr > 0)
- file_name = compiler->file_name_stack[compiler->file_name_stack_ptr - 1];
- else
- file_name = NULL;
-
if (min_atom_length < 2 && compiler->error_report_function != NULL)
{
snprintf(
@@ -601,11 +595,7 @@ YR_STRING* yr_parser_reduce_string_declaration(
string->identifier,
min_atom_length == 0 ? " (critical!)" : "");
- compiler->error_report_function(
- YARA_ERROR_LEVEL_WARNING,
- file_name,
- yyget_lineno(yyscanner),
- message);
+ yywarning(yyscanner, message);
}
_exit:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git
More information about the forensics-changes
mailing list