locked
Replacing missing data available in different column of CSV file RRS feed

  • Question

  • User-718146471 posted

    Hey folks, I am trying to figure out the best way to populate data in a CSV file by reading it into memory, removing any bad formatting, then search for null fields and pull details from the field that has the full description. This is what the data looks like (if loaded into Excel):

    Count<o:p></o:p>

    Content.Vuln.CVE<o:p></o:p>

    Content.Vuln.CheckName<o:p></o:p>

    Vendor<o:p></o:p>

    Software<o:p></o:p>

    200750<o:p></o:p>

    CVE-2014-3735<o:p></o:p>

    Intel Indeo Video ir41_32.ax Crafted File Denial of Service<o:p></o:p>

    Intel<o:p></o:p>

    Indeo Video<o:p></o:p>

    200070<o:p></o:p>

    CVE-2007-6753<o:p></o:p>

    Microsoft Windows Environment Variable Expansion Library Loading Vulnerability (329308)<o:p></o:p>

    Microsoft<o:p></o:p>

    Windows OS<o:p></o:p>

    196127<o:p></o:p>

    CVE-2015-3095<o:p></o:p>

    Adobe Acrobat Reader CoolType CharString Denial of Service<o:p></o:p>

     <o:p></o:p>

     <o:p></o:p>

    195141<o:p></o:p>

    CVE-2010-4182<o:p></o:p>

    Microsoft Data Access Objects Library 3.6 DLL Hijacking Vulnerability (2269637)<o:p></o:p>

    Microsoft<o:p></o:p>

    Windows OS<o:p></o:p>

    192232<o:p></o:p>

    CVE-2010-4669<o:p></o:p>

    Microsoft Windows Ipv6 Router Advertisement Denial Of Service<o:p></o:p>

    Microsoft<o:p></o:p>

    Windows OS<o:p></o:p>

    190327<o:p></o:p>

    CVE-2006-7192<o:p></o:p>

    Microsoft ASP.NET Request Filter Bypass<o:p></o:p>

    Microsoft<o:p></o:p>

    ASP.Net<o:p></o:p>

    189990<o:p></o:p>

    CVE-2012-4603<o:p></o:p>

    Citrix XenApp Online Plug-in / Receiver Remote Code Execution<o:p></o:p>

    Unknown CVE ID<o:p></o:p>

    Unknown CVE ID<o:p></o:p>

    189626<o:p></o:p>

    CVE-2012-0201<o:p></o:p>

    IBM Personal Communications WS File Processing Buffer Overflow Remote Code Execution<o:p></o:p>

    IBM<o:p></o:p>

    Personal Communication <o:p></o:p>

    188986<o:p></o:p>

    CVE-2013-3026<o:p></o:p>

    IBM Lotus Quickr For Domino qp2.cab ActiveX Control Unspecified Arbitrary Code Execution Vulnerability<o:p></o:p>

    IBM<o:p></o:p>

    Lotus Quickr for Domino<o:p></o:p>

    185174<o:p></o:p>

    CVE-2015-2464<o:p></o:p>

    (MS15-080) Microsoft Windows TrueType Font Parsing Remote Code Execution V (3078662)<o:p></o:p>

     <o:p></o:p>

     <o:p></o:p>

    185153<o:p></o:p>

    CVE-2015-2463<o:p></o:p>

    (MS15-080) Microsoft Windows TrueType Font Parsing Remote Code Execution IV (3078662)<o:p></o:p>

     <o:p></o:p>

     <o:p></o:p>

    185119<o:p></o:p>

    CVE-2015-2456<o:p></o:p>

    (MS15-080) Microsoft Windows TrueType Font Parsing Remote Code Execution III (3078662)<o:p></o:p>

     <o:p></o:p>

     <o:p></o:p>

    185022<o:p></o:p>

    CVE-2015-2455<o:p></o:p>

    (MS15-080) Microsoft Windows TrueType Font Parsing Remote Code Execution II (3078662)<o:p></o:p>

     <o:p></o:p>

     <o:p></o:p>

    184233<o:p></o:p>

    CVE-2015-2435<o:p></o:p>

    (MS15-080) Microsoft Windows TrueType Font Parsing Remote Code Execution I (3078662)<o:p></o:p>

     <o:p></o:p>

     <o:p></o:p>

    183818<o:p></o:p>

    CVE-2015-1671<o:p></o:p>

    (MS15-044) Microsoft Windows GDI+ TrueType Font Parsing Remote Code Execution (3057110)<o:p></o:p>

    Microsoft<o:p></o:p>

    Windows OS<o:p></o:p>

    183499<o:p></o:p>

    CVE-2015-2470<o:p></o:p>

    (MS15-081) Microsoft Office Memory Corruption Integer Underflow Remote Code Execution (3080790)<o:p></o:p>

     <o:p></o:p>

     <o:p></o:p>

    182835<o:p></o:p>

    CVE-2015-1682<o:p></o:p>

    (MS15-046) Microsoft Office Memory Corruption I Remote Code Execution (3057181)<o:p></o:p>

    Microsoft<o:p></o:p>

    Office<o:p></o:p>

    182427<o:p></o:p>

    CVE-2015-2431<o:p></o:p>

    (MS15-080) Microsoft Office Graphics Component Remote Code Execution (3078662)<o:p></o:p>

     <o:p></o:p>

     <o:p></o:p>

    182260<o:p></o:p>

    CVE-2015-1760<o:p></o:p>

    (MS15-059) Microsoft Office Use-After-Free Remote Code Execution II (3064949)<o:p></o:p>

     <o:p></o:p>

     <o:p></o:p>

    182151<o:p></o:p>

    CVE-2015-2466<o:p></o:p>

    (MS15-081) Microsoft Office Memory Corruption II Remote Code Execution (3080790)<o:p></o:p>

     <o:p></o:p>

     <o:p></o:p>

    181904<o:p></o:p>

    CVE-2015-1642<o:p></o:p>

    (MS15-081) Microsoft Office Memory Corruption I Remote Code Execution (3080790)<o:p></o:p>

     <o:p></o:p>

     <o:p></o:p>

    180948<o:p></o:p>

    CVE-2015-1770<o:p></o:p>

    (MS15-059) Microsoft Office Uninitialized Memory Use Remote Code Execution (3064949)<o:p></o:p>

     <o:p></o:p>

     <o:p></o:p>

    178996<o:p></o:p>

    CVE-2015-2510<o:p></o:p>

    (MS15-097) Microsoft Windows Graphics Font Parsing Remote Code Execution (3089656)<o:p></o:p>

     <o:p></o:p>

     <o:p></o:p>

    174249<o:p></o:p>

    CVE-2013-0007<o:p></o:p>

    (MS13-002) Microsoft XML Core Services Remote Code Execution II (2756145)<o:p></o:p>

    Microsoft<o:p></o:p>

    XML Core Services <o:p></o:p>

    173783<o:p></o:p>

    CVE-2012-1889<o:p></o:p>

    (MS12-043) Vulnerability in Microsoft XML Core Services Could Allow Remote Code Execution (2722479)<o:p></o:p>

    Microsoft<o:p></o:p>

    XML Core Services <o:p></o:p>

    As you can see, there are several lines that have a blank vendor and software column. How can I take these and parse out the second and third word in C# for my web application?

    Friday, October 7, 2016 7:39 PM

Answers

  • User2117486576 posted

    If it is ALWAYS the second and third words you can do something simple like:

     string text = "(MS15-097) Microsoft Windows Graphics Font Parsing Remote Code Execution (3089656)";
                string[] words = text.Split(new[] { ' ' });
                if (words.Length > 2)
                {
                    var secondWord = words[1];
                    var thirdWord = words[2];
                }

    This is highly dependent upon the values in the column and seems a little fragile to me but it may serve your purpose.

    If the names of possible vendors is known at compile time and is short enough to be manageable you could parse the text for the vendors name and take the following word as the software name.  Probably depends too on your ultimate goal; is this a one time effort to import data or will it be an ongoing process.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 11, 2016 9:39 PM

All replies

  • User347430248 posted

    Hi BBcomponent1,

    you can first load the data in the Excel file and then try to check for the null records and formatting.

    you can try to use Excel.Interop to perform these operations.

    or you can try to use open xml to do this job.

    also try to use some third party libraries.

    Regards

    Deepak

    Monday, October 10, 2016 4:46 AM
  • User-718146471 posted

    Deepak, is there another way without using MS office interop or OpenXML format? I was kind of hoping I could toss the text into an array and parse it out that way. These files are strictly text based CSV so I am not reading excel formatted files.

    Tuesday, October 11, 2016 3:27 PM
  • User2117486576 posted

    If it is ALWAYS the second and third words you can do something simple like:

     string text = "(MS15-097) Microsoft Windows Graphics Font Parsing Remote Code Execution (3089656)";
                string[] words = text.Split(new[] { ' ' });
                if (words.Length > 2)
                {
                    var secondWord = words[1];
                    var thirdWord = words[2];
                }

    This is highly dependent upon the values in the column and seems a little fragile to me but it may serve your purpose.

    If the names of possible vendors is known at compile time and is short enough to be manageable you could parse the text for the vendors name and take the following word as the software name.  Probably depends too on your ultimate goal; is this a one time effort to import data or will it be an ongoing process.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 11, 2016 9:39 PM
  • User-718146471 posted

    Cool, what I can say is the vendor will always be the first word and software is second, unless it is a Microsoft KB article, then those would be the second and third words. I am sure I can adapt this code to look out to see if the first word begins with KB, move to the second word as first and third as second. :)

    Tuesday, October 11, 2016 9:43 PM