mirror of
https://github.com/cve-search/cpe-guesser.git
synced 2024-11-24 07:47:23 +00:00
chg: [valkey] get rid of Redis and moved to Valkey
This commit is contained in:
parent
9cc2bef2bc
commit
facc75d06d
5 changed files with 17 additions and 17 deletions
14
README.md
14
README.md
|
@ -5,12 +5,12 @@ be used against [cve-search](https://github.com/cve-search/cve-search) to do act
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Redis
|
- [Valkey](https://valkey.io/)
|
||||||
- Python
|
- Python
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
To use CPE guesser, you have to initialise the Redis database with `import.py`.
|
To use CPE guesser, you have to initialise the [Valkey](https://valkey.io/) database with `import.py`.
|
||||||
|
|
||||||
Then you can use the software with `lookup.py` to find the most probable CPE matching the keywords provided.
|
Then you can use the software with `lookup.py` to find the most probable CPE matching the keywords provided.
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ If you don't want to install it locally, there is a public online version. Check
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
|
|
||||||
#### Single image with existing Redis
|
#### Single image with existing Valkey
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker build . -t cpe-guesser:l.0
|
docker build . -t cpe-guesser:l.0
|
||||||
|
@ -157,9 +157,9 @@ sharing common names or name is composed of multiple words.
|
||||||
|
|
||||||
Split vendor name and product name (such as `_`) into single word(s) and then canonize the word. Building an inverse index using
|
Split vendor name and product name (such as `_`) into single word(s) and then canonize the word. Building an inverse index using
|
||||||
the cpe vendor:product format as value and the canonized word as key. Then cpe guesser creates a ranked set with the most common
|
the cpe vendor:product format as value and the canonized word as key. Then cpe guesser creates a ranked set with the most common
|
||||||
cpe (vendor:product) per version to give a probability of the CPE appearance.
|
cpe (vendor:product) per version to give a probability of the CPE appearance.
|
||||||
|
|
||||||
### Redis structure
|
### Valkey structure
|
||||||
|
|
||||||
- `w:<word>` set
|
- `w:<word>` set
|
||||||
- `s:<word>` sorted set with a score depending of the number of appearance
|
- `s:<word>` sorted set with a score depending of the number of appearance
|
||||||
|
@ -168,5 +168,5 @@ cpe (vendor:product) per version to give a probability of the CPE appearance.
|
||||||
|
|
||||||
Software is open source and released under a 2-Clause BSD License
|
Software is open source and released under a 2-Clause BSD License
|
||||||
|
|
||||||
Copyright (C) 2021-2024 Alexandre Dulaunoy
|
Copyright (C) 2021-2024 Alexandre Dulaunoy
|
||||||
Copyright (C) 2021-2024 Esa Jokinen
|
Copyright (C) 2021-2024 Esa Jokinen
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
redis
|
valkey[libvalkey]
|
||||||
falcon
|
falcon
|
||||||
dynaconf
|
dynaconf
|
||||||
|
|
|
@ -8,7 +8,7 @@ import urllib.request
|
||||||
import gzip
|
import gzip
|
||||||
import shutil
|
import shutil
|
||||||
import xml.sax
|
import xml.sax
|
||||||
import redis
|
import valkey
|
||||||
import time
|
import time
|
||||||
from dynaconf import Dynaconf
|
from dynaconf import Dynaconf
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ from dynaconf import Dynaconf
|
||||||
settings = Dynaconf(settings_files=["../config/settings.yaml"])
|
settings = Dynaconf(settings_files=["../config/settings.yaml"])
|
||||||
cpe_path = settings.cpe.path
|
cpe_path = settings.cpe.path
|
||||||
cpe_source = settings.cpe.source
|
cpe_source = settings.cpe.source
|
||||||
rdb = redis.Redis(host=settings.redis.host, port=settings.redis.port, db=8)
|
rdb = valkey.Valkey(host=settings.valkey.host, port=settings.valkey.port, db=8)
|
||||||
|
|
||||||
|
|
||||||
class CPEHandler(xml.sax.ContentHandler):
|
class CPEHandler(xml.sax.ContentHandler):
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
server:
|
server:
|
||||||
port: 8000
|
port: 8000
|
||||||
redis:
|
valkey:
|
||||||
host: 127.0.0.1
|
host: 127.0.0.1
|
||||||
port: 6379
|
port: 6379
|
||||||
cpe:
|
cpe:
|
||||||
path: '../data/official-cpe-dictionary_v2.3.xml'
|
path: '../data/official-cpe-dictionary_v2.3.xml'
|
||||||
source: 'https://nvd.nist.gov/feeds/xml/cpe/dictionary/official-cpe-dictionary_v2.3.xml.gz'
|
source: 'https://nvd.nist.gov/feeds/xml/cpe/dictionary/official-cpe-dictionary_v2.3.xml.gz'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import redis
|
import valkey
|
||||||
from dynaconf import Dynaconf
|
from dynaconf import Dynaconf
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
|
@ -10,9 +10,9 @@ settings = Dynaconf(settings_files=["../config/settings.yaml"])
|
||||||
|
|
||||||
class CPEGuesser:
|
class CPEGuesser:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.rdb = redis.Redis(
|
self.rdb = valkey.Valkey(
|
||||||
host=settings.redis.host,
|
host=settings.valkey.host,
|
||||||
port=settings.redis.port,
|
port=settings.valkey.port,
|
||||||
db=8,
|
db=8,
|
||||||
decode_responses=True,
|
decode_responses=True,
|
||||||
)
|
)
|
||||||
|
@ -35,4 +35,4 @@ class CPEGuesser:
|
||||||
rank = self.rdb.zrank("rank:cpe", cpe)
|
rank = self.rdb.zrank("rank:cpe", cpe)
|
||||||
ranked.append((rank, cpe))
|
ranked.append((rank, cpe))
|
||||||
|
|
||||||
return sorted(ranked)
|
return sorted(ranked, reverse=True)
|
||||||
|
|
Loading…
Reference in a new issue