Giter VIP home page Giter VIP logo

go-cpe's Introduction

go-cpe

Build Status Coverage Status Go Report Card GoDoc MIT License

A Go library for CPE(A Common Platform Enumeration 2.3)

go-cpe is a implementation of the CPE Naming and Matching algorithms, as described in NIST IRs 7695 and 7696.

For the reference Java implementation, see: https://cpe.mitre.org/specification/CPE_Reference_Implementation_Sep2011.zipx

Installation and Usage

Installation can be done with a normal go get:

$ go get github.com/knqyf263/go-cpe/...

Compare

See example

package main

import (
	"fmt"

	"github.com/knqyf263/go-cpe/matching"
	"github.com/knqyf263/go-cpe/naming"
)

func main() {
	wfn, err := naming.UnbindURI("cpe:/a:microsoft:internet_explorer%01%01%01%01:8%02:beta")
	if err != nil {
		fmt.Println(err)
		return
	}
	wfn2, err := naming.UnbindFS(`cpe:2.3:a:microsoft:internet_explorer:8.0.6001:beta:*:*:*:*:*:*`)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(matching.IsDisjoint(wfn, wfn2))
	fmt.Println(matching.IsEqual(wfn, wfn2))
	fmt.Println(matching.IsSubset(wfn, wfn2))
	fmt.Println(matching.IsSuperset(wfn, wfn2))
}

Contribute

  1. fork a repository: github.com/knqyf263/go-cpe to github.com/you/repo
  2. get original code: go get github.com/knqyf263/go-cpe
  3. work on original code
  4. add remote to your repo: git remote add myfork https://github.com/you/repo.git
  5. push your changes: git push myfork
  6. create a new Pull Request

License

MIT

Author

Teppei Fukuda

go-cpe's People

Contributors

knqyf263 avatar sadayuki-matsuno avatar santosh653 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

go-cpe's Issues

is this repo still alive?

I noticed that the last issue was not responded.
But still, I found that the matching doesnt seem to work as expected:

` cpe1_param := strings.ReplaceAll( c.QueryParam("cpe1"), ".", "\.")
cpe2_param := strings.ReplaceAll(c.QueryParam("cpe2"), ".", "\.")

           if matching.IsDisjoint(cpe1, cpe2) {
		match = "IsDisjoint"
	}
	if matching.IsEqual(cpe1, cpe2) {
		match = "IsEqual"
	}
	if matching.IsSuperset(cpe1, cpe2) {
		match = "IsSuperset"
	}
	if matching.IsSubset(cpe1, cpe2) {
		match = "IsSubset"
	}

`
match will always be the last one, it doesn't matter the condition. In other words, if I invert the order of matching.IsSubset by matching.IsSuperset, then match = "IsSuperset"

Which means that the matching doesn't seems to be working as expected..

Version matching results are incorrect

Version matching seems to only consider a prefix. For example, when checking whether cpe:2.3:o:linux:linux_kernel:4.4.1:*:*:*:*:*:*:* is a superset of cpe:2.3:o:linux:linux_kernel:4.4.19:*:*:*:*:*:*:*, the answer comes back as true when I would have expected it to be false.

Likewise for 3.10.2 with 3.10.20, and other such cases.

gore version 0.3.0  :help for help
gore> :import github.com/knqyf263/go-cpe/common
gore> :import github.com/knqyf263/go-cpe/matching
gore> :import github.com/knqyf263/go-cpe/naming
gore> a, err := naming.UnbindFS("cpe:2.3:o:linux:linux_kernel:4.4.1:*:*:*:*:*:*:*")
common.WellFormedName{"target_hw":common.LogicalValue{Any:true, Na:false}, "part":"o", "product":"linux_kernel", "version":"4\\.4\\.1", "update":common.LogicalValue{Any:true, Na:false}, "edition":common.LogicalValue{Any:true, Na:false}, "language":common.LogicalValue{Any:true, Na:false}, "sw_edition":common.LogicalValue{Any:true, Na:false}, "target_sw":common.LogicalValue{Any:true, Na:false}, "other":common.LogicalValue{Any:true, Na:false}, "vendor":"linux"}
<nil>
gore> b, err := naming.UnbindFS("cpe:2.3:o:linux:linux_kernel:4.4.19:*:*:*:*:*:*:*")
common.WellFormedName{"target_sw":common.LogicalValue{Any:true, Na:false}, "target_hw":common.LogicalValue{Any:true, Na:false}, "part":"o", "vendor":"linux", "update":common.LogicalValue{Any:true, Na:false}, "edition":common.LogicalValue{Any:true, Na:false}, "language":common.LogicalValue{Any:true, Na:false}, "sw_edition":common.LogicalValue{Any:true, Na:false}, "other":common.LogicalValue{Any:true, Na:false}, "product":"linux_kernel", "version":"4\\.4\\.19"}
<nil>
gore> matching.IsSuperset(a, b)
true

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.