Commit Graph

139 Commits

Author SHA1 Message Date
Sida Chen
43f3ea87d8 pgsql: Move batch queries to corresponding modules 2019-03-12 22:23:30 -04:00
Sida Chen
a33050637b pgsql: Move extra logic in pgsql.go to util folder
- pgsql/util/error.go contains error handling logic
- pgsql/page/page.go contains the page struct
- pgsql/monitoring contains the prometheus logic
- pgsql/pgsession contains the pgsession struct
2019-03-12 22:23:30 -04:00
Sida Chen
8bebea3643 pgsql: Split testutil.go into multiple files
- assertion.go assertions used in pgsql tests
- data.go contains go representation of data.sql
- testdb.go contains test db/tx creation logic
- testutil.go contains misc other things
2019-03-12 22:23:30 -04:00
Ales Raszka
d77dc0f0ae Use struct as a map key instead of string
String was used when Feature contains PotentialNamespace. Since it was
moved to LayerFeature we can use struct as map key instead of string.
2019-03-08 09:51:40 +01:00
Ales Raszka
a8a91379d9 Add test for potential namespace
Test verifies that potential namespace is stored in database and it can
be loaded back to structure.

The commit also fixes few typos and bugs.
2019-03-08 09:51:19 +01:00
Ales Raszka
60b0bd27fa Add namespace_id as constraints to layer_feature
If layer contains more than one potential namespace, features will be
created for each namespace. Layer_feature table now has to contains one
more constrains (namespace_id).
2019-03-07 11:22:54 +01:00
Ales Raszka
60ef726677 Move PotentialNamespace to LayerFeature
PotentialNamespace should be in LayerFeature instead of Feature struct.
Feature extractors were updated to return LayerFeature instead of
Feature.
2019-03-07 11:22:54 +01:00
Ales Raszka
44c4a6f3ce Store PotentialNamespace in database
PotentialNamespace is part of layer_feature table and it is also stored
in namespace table.
2019-03-07 11:22:32 +01:00
Ales Raszka
34c2d96b36 featurefmt: Extract PotentialNamespace
PotentialNamespace is feature namespace extracted while detecting
features in layer. It will server for special feature detector. The
current detectors return empty namespace.
2019-03-07 11:22:32 +01:00
Sida Chen
b03f1bc3a6 pgsql: Fix failed tests 2019-03-06 13:44:23 -05:00
Sida Chen
ed9c6baf4f pgsql: Fix pgsql test 2019-03-06 11:32:25 -05:00
Sida Chen
046b0e49d1 Add missing licenses 2019-03-05 11:42:59 -05:00
Jimmy Zelinskie
4fa03d1c78
Merge pull request #723 from jzelinskie/lock-tx
database: make locks SOI & add Extend method
2019-02-28 15:59:58 -05:00
Jimmy Zelinskie
961c7d4680 database: add test for lock expiration 2019-02-28 15:54:57 -05:00
Jimmy Zelinskie
a4e7873d14 database: make locks SOI & add Extend method 2019-02-28 15:46:31 -05:00
Sida Chen
f7e54c1a28
Merge pull request #695 from saromanov/fix-unchecked-error
pgsql: fix unchecked error
2019-02-27 13:05:52 -05:00
Sida Chen
5bf8365f7b pgsql: Prevent inserting invalid entry to database 2019-02-26 10:26:49 -05:00
Sida Chen
8aae73f1c8 pgsql: Remove unnecessary logs 2019-02-26 10:26:49 -05:00
Sida Chen
73bc2bc36b
Merge pull request #672 from KeyboardNerd/source_package/feature_type
Implement Feature types
2019-02-20 15:58:50 -05:00
Sida Chen
5a94499fdb update according to comments 2019-02-19 17:57:38 -05:00
Sida Chen
79af05e67d pgsql: Fix postgres queries for feature_type 2019-02-19 16:48:42 -05:00
Sida Chen
073c685c5b pgsql: Add proper tests for database migration 2019-02-19 16:48:42 -05:00
Sida Chen
00eed77b45 database: Add feature_type database model 2019-02-19 16:48:42 -05:00
Sida Chen
c6c8fce39a pgsql: Add feature_type to initial schema
feature_type is for differentiating the binary packages and source
packages.
2019-02-19 16:43:35 -05:00
Jimmy Zelinskie
cafe0976a4
Merge pull request #685 from jzelinskie/updater-cleanup
updater: remove FindLock(), use errgroup to avoid races
2019-02-14 14:57:59 -05:00
Sergey
a57d806717
pgsql: fix unchecked error 2019-01-21 17:57:52 +05:00
Ales Raszka
015a79fd5a Layer: replace arrays with slices
The current code is much cleaner because it doesn't use indexes + it
should be more memory efficient.
2019-01-16 09:12:34 +01:00
Ales Raszka
90f5592095 Feature: replace arrays with slices
The current code is much cleaner because it doesn't use indexes + it
should be more memory efficient.
2019-01-16 09:12:33 +01:00
Jimmy Zelinskie
399deab100 database: remove FindLock() 2019-01-10 13:50:46 -05:00
Sida Chen
f759dd54c0 database: Replace Parent Feature with source metadata
Feature's source feature string is directly stored in the database
instead of having the parent pointer to simplify the database.
2018-10-15 16:26:24 -04:00
Sida Chen
3fe894c5ad database: Add parent feature pointer to Feature struct
Feature now has a pointer to parent feature. If a vulnerability affects
a parent feature, this child feature will be affected.
2018-10-09 19:52:10 -04:00
Sida Chen
e657d26313 database: move dbutil and testutil to database from pkg
Move dbutil and testutil to database from pkg
Rename all "result"
2018-10-08 12:10:35 -04:00
Sida Chen
0c1b80b2ed pgsql: Implement database queries for detector relationship
* Refactor layer and ancestry
* Add tests
* Fix bugs introduced when the queries were moved
2018-10-08 11:27:15 -04:00
Sida Chen
9c49d9dc55 pgsql: Move queries to corresponding files
Aggregate queries in their corresponding files instead of having the
single file for every queries because the database is more complicated.
2018-10-08 10:42:40 -04:00
Sida Chen
dca2d4e597 pgsql: Add detector to database schema
'detector' table is added to store the metadata of detectors.
'layer_feature', 'layer_namespace', and 'ancestry_feature' tables are
modified to store the detection relationship between the
feature/namespace with the detector.
2018-10-08 10:42:40 -04:00
Sida Chen
53433090a3 pgsql: update the query format 2018-09-19 14:33:08 -04:00
Sida Chen
e160616723 database: Use LayerWithContent as Layer 2018-09-13 13:21:39 -04:00
Sida Chen
ff9303905b database: changed Notification interface name 2018-09-11 14:24:09 -04:00
Sida Chen
6c69377343
Merge pull request #614 from KeyboardNerd/sidac/simplify
Replace Ancestry with AncestryWithContent struct in database models
2018-09-11 10:50:53 -04:00
Sida Chen
5d725e67b0 Replace Ancestry with AncestryWithContent struct in database models
As one of the steps to simplifies the codebase, the AncestryWithContent
struct is renamed to Ancestry, and Ancestry is removed. It will cause
the PostAncestry request to be slower.
2018-09-10 12:48:23 -04:00
Jimmy Zelinskie
0565938956 pkg/pagination: add token type
This change pulls as much pagination logic out of the database
implementation as possible. Database implementations should now be able
to marshal whatever state they need into opaque tokens with the
utilities in the pagination package.
2018-09-07 16:26:56 -04:00
Jimmy Zelinskie
d193b46449 pkg/pagination: init
This change refactors a lot of the code dealing with pagination so that
fernet implementation details do not leak.

- Deletes database/pgsql/token
- Introduces a pagination package
- Renames idPageNumber to Page and add a constructor and method.
2018-09-07 16:13:51 -04:00
Sida Chen
2827b9342b Update Database and Worker implementation for layer-wise feature
Feature extraction algorithm is changed to associate features with
ancestry layer. Database is updated to keep the relationship.
2018-09-06 13:56:03 -04:00
Jimmy Zelinskie
4491bedf2e database/pgsql: move token lib 2017-08-21 16:25:13 -04:00
Sida Chen
57a4f97780 pgSQL: fixed invalidating vulnerability cache query. 2017-08-14 16:14:55 -04:00
Sida Chen
a5c6400065 database: postgres implementation with tests. 2017-08-10 11:25:29 -04:00
Jimmy Zelinskie
abd7d2e013 Merge pull request #394 from KeyboardNerd/multiplens
added support for detecting multiple namespaces in a layer
2017-05-24 17:22:08 -04:00
Sida Chen
75d5d40d79 featurens: added multiple namespace testing for namespace detector 2017-05-24 17:18:11 -04:00
Sida Chen
bffa6499b7 added support for detect multiple namespaces in a layer
created table layer_namespace to store the many to many unique mapping of layers and namespaces
changed v1 api to provide a list of namespaces for each layer
changed namespace detector to use all registered detectors to detect namespaces
updated tests for multiple namespaces

Fixes #150
2017-05-24 17:01:51 -04:00
Jimmy Zelinskie
c2d8aec157 Merge pull request #382 from caipre/patch-1
pgsql: Change layer name column data type
2017-05-19 20:07:53 -04:00