Browse code

Add new target type for json properties file and scanning of the same.

Steven Morgan authored on 2014/04/30 06:15:07
Showing 5 changed files
... ...
@@ -120,6 +120,7 @@ static const struct ftmap_s {
120 120
     { "CL_TYPE_OOXML_WORD",	CL_TYPE_OOXML_WORD     	},
121 121
     { "CL_TYPE_OOXML_PPT",	CL_TYPE_OOXML_PPT     	},
122 122
     { "CL_TYPE_OOXML_XL",	CL_TYPE_OOXML_XL     	},
123
+    { "CL_TYPE_INTERNAL",	CL_TYPE_INTERNAL     	},
123 124
     { NULL,			CL_TYPE_IGNORED		}
124 125
 };
125 126
 
... ...
@@ -83,6 +83,7 @@ typedef enum {
83 83
     CL_TYPE_OOXML_WORD,
84 84
     CL_TYPE_OOXML_PPT,
85 85
     CL_TYPE_OOXML_XL,
86
+    CL_TYPE_INTERNAL,
86 87
 
87 88
     /* Section for partition types */
88 89
     CL_TYPE_PART_ANY, /* unknown partition type */
... ...
@@ -180,6 +180,7 @@ static const char *ftypes_int[] = {
180 180
   "1:510:55AA:Disk Image - Master Boot Record:CL_TYPE_ANY:CL_TYPE_MBR:77",
181 181
   "0:512:4546492050415254:Disk Image - GUID Partition Table:CL_TYPE_ANY:CL_TYPE_GPT:77",
182 182
   "1:0:4552{510}504D0000:Disk Image - Apple Partition Map:CL_TYPE_ANY:CL_TYPE_APM:77",
183
+  "0:2:224d61676963223a20224a534f4e22:Internal properties:CL_TYPE_ANY:CL_TYPE_INTERNAL:77",
183 184
   NULL
184 185
 };
185 186
 
... ...
@@ -140,7 +140,7 @@ struct cli_mtarget {
140 140
     uint8_t target_count; /* must be synced with non-zero values in the target array */
141 141
 };
142 142
 
143
-#define CLI_MTARGETS 13
143
+#define CLI_MTARGETS 14
144 144
 static const struct cli_mtarget cli_mtargets[CLI_MTARGETS] =  {
145 145
     { {0, 0},                                   "GENERIC",      0,  0, 1, 1 },
146 146
     { {CL_TYPE_MSEXE, 0},                       "PE",           1,  0, 1, 1 },
... ...
@@ -154,7 +154,8 @@ static const struct cli_mtarget cli_mtargets[CLI_MTARGETS] =  {
154 154
     { {CL_TYPE_MACHO, CL_TYPE_MACHO_UNIBIN},    "MACH-O",       9,  1, 0, 2 },
155 155
     { {CL_TYPE_PDF, 0},                         "PDF",         10,  1, 0, 1 },
156 156
     { {CL_TYPE_SWF, 0},                         "FLASH",       11,  1, 0, 1 },
157
-    { {CL_TYPE_JAVA, 0},                        "JAVA",        12,  1, 0, 1 }
157
+    { {CL_TYPE_JAVA, 0},                        "JAVA",        12,  1, 0, 1 },
158
+    { {CL_TYPE_INTERNAL, 0},                    "INTERNAL",    13,  1, 0, 1 }
158 159
 };
159 160
 
160 161
 #define CLI_OFF_ANY         0xffffffff
... ...
@@ -2609,6 +2609,9 @@ static int magic_scandesc(cli_ctx *ctx, cli_file_t type)
2609 2609
                     early_ret_from_magicscan(CL_EMEM);       
2610 2610
                 }
2611 2611
                 ctx->wrkproperty = ctx->properties;
2612
+                if (ret = cli_jsonstr(ctx->properties, "Magic", "JSON") != CL_SUCCESS) {
2613
+                    early_ret_from_magicscan(ret);
2614
+                }
2612 2615
 	    } else { /* turn off property collection flag for file types we don't care about */
2613 2616
                 ctx->options &= ~CL_SCAN_FILE_PROPERTIES;	
2614 2617
             }
... ...
@@ -3396,6 +3399,8 @@ static int scan_common(int desc, cl_fmap_t *map, const char **virname, unsigned
3396 3396
         }
3397 3397
         else {
3398 3398
             cli_errmsg("%s\n", jstring);
3399
+            ctx.options &= ~CL_SCAN_FILE_PROPERTIES;
3400
+            rc = cli_mem_scandesc(jstring, strlen(jstring), &ctx);
3399 3401
         }
3400 3402
         json_object_put(ctx.properties); // frees
3401 3403
     }