Giter Site home page Giter Site logo

cpe23's People

Contributors

jtsymon avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

kernelsmith

cpe23's Issues

whitespace should not be permitted

Hi @jtsymon,

I'm using your gem in a project and while writing some RSpec for my code, I noticed white space is not properly handled. I expected the gem would either convert the whitespace to _ or raise an error if one of the parts contained whitespace, but neither happens. In my example the vendor is "Vendie Space". The CPE spec http://csrc.nist.gov/publications/nistir/ir7696/NISTIR-7696-CPE-Matching.pdf (sorry, a PDF link is all I could find) addresses this in section 5.3.2, here's the quote (2nd item).

I can create a PR if you'd like. I was going to do the conversion on the way in (in parse, but might also need it in initialize https://github.com/jtsymon/cpe23/blob/master/lib/cpe23.rb#L189) vs throwing an exception since plenty of vendors and products have whitespace in them and making the caller handle that seems wrong.

Let me know what you think

1. Uppercase letters, lowercase letters or digit characters MAY be used (ASCII x41-x5a, x30-x39 and x61-x7a).
2. The underscore (x5f) MAY be used, and it SHOULD be used in place of whitespace characters (which SHALL NOT be used).
[10] pry(main)> cpe2 = Cpe23.new(part: "o", product: "ProdOS", vendor: "Vendie Space", version: "1.2.3")
=> #<Cpe23:0x00007f69be014cd8
 @edition=nil,
 @language=nil,
 @other=nil,
 @part="o",
 @product="ProdOS",
 @sw_edition=nil,
 @target_hw=nil,
 @target_sw=nil,
 @update=nil,
 @vendor="Vendie Space",
 @version="1.2.3">
[11] pry(main)> cpe2.to_s
=> "cpe:2.3:o:vendie space:prodos:1.2.3:::::::"
[12] pry(main)> cpe2.to_wfn
=> "wfn:[part=\"o\",vendor=\"vendie space\",product=\"prodos\",version=\"1.2.3\",update=NA,edition=NA,language=NA,sw_edition=NA,target_sw=NA,target_hw=NA,other=NA]"

pry(main)> cpe = Cpe23.parse "cpe:2.3:o:vendie space:prodos:1.3.5:::::::"
=> #<Cpe23:0x00007f69bebf7d48
 @edition=nil,
 @language=nil,
 @other=nil,
 @part="o",
 @product="prodos",
 @sw_edition=nil,
 @target_hw=nil,
 @target_sw=nil,
 @update=nil,
 @vendor="vendie space",
 @version="1.3.5">
[8] pry(main)> cpe.to_s
=> "cpe:2.3:o:vendie space:prodos:1.3.5:::::::"
[9] pry(main)> cpe.to_wfn
=> "wfn:[part=\"o\",vendor=\"vendie space\",product=\"prodos\",version=\"1.3.5\",update=NA,edition=NA,language=NA,sw_edition=NA,target_sw=NA,target_hw=NA,other=NA]"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.