mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 18:15:42 +01:00
Merge branch 'main' into rolie-categories
This commit is contained in:
commit
ed2df66ce6
4 changed files with 61 additions and 4 deletions
|
|
@ -3,8 +3,8 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2021 German Federal Office for Information Security (BSI) <https://www.bsi.bund.de>
|
||||
// Software-Engineering: 2021 Intevation GmbH <https://intevation.de>
|
||||
// SPDX-FileCopyrightText: 2022 German Federal Office for Information Security (BSI) <https://www.bsi.bund.de>
|
||||
// Software-Engineering: 2022 Intevation GmbH <https://intevation.de>
|
||||
|
||||
package main
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ func (c *controller) upload(r *http.Request) (interface{}, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Validate againt JSON schema.
|
||||
// Validate against JSON schema.
|
||||
if !c.cfg.NoValidation {
|
||||
validationErrors, err := csaf.ValidateCSAF(content)
|
||||
if err != nil {
|
||||
|
|
@ -167,7 +167,7 @@ func (c *controller) upload(r *http.Request) (interface{}, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// Validate against remote validator
|
||||
// Validate against remote validator.
|
||||
if c.cfg.RemoteValidator != nil {
|
||||
validator, err := c.cfg.RemoteValidator.Open()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -318,6 +318,24 @@ func (a *Aggregator) Validate() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalText implements the encoding.TextUnmarshaller interface.
|
||||
func (mdv *MetadataVersion) UnmarshalText(data []byte) error {
|
||||
s, err := metadataVersionPattern(data)
|
||||
if err == nil {
|
||||
*mdv = MetadataVersion(s)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// UnmarshalText implements the encoding.TextUnmarshaller interface.
|
||||
func (mdr *MetadataRole) UnmarshalText(data []byte) error {
|
||||
s, err := metadataRolePattern(data)
|
||||
if err == nil {
|
||||
*mdr = MetadataRole(s)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// UnmarshalText implements the encoding.TextUnmarshaller interface.
|
||||
func (ac *AggregatorCategory) UnmarshalText(data []byte) error {
|
||||
s, err := aggregatorCategoryPattern(data)
|
||||
|
|
|
|||
|
|
@ -104,6 +104,20 @@ curl https://localhost:8443/cgi-bin/csaf_provider.go/create --cert-type p12 --ce
|
|||
|
||||
popd
|
||||
|
||||
# Setup validation service
|
||||
./setupValidationService.sh
|
||||
|
||||
# Disable exit for the next error as these is expected.
|
||||
set +e
|
||||
|
||||
# Wait for the service to be started
|
||||
for ((i = 1; i <= 10; i++)); do
|
||||
if [ $(curl -IL http://localhost:3000/api/v1/tests | grep -c HTTP ) != "0" ]; then
|
||||
break
|
||||
fi
|
||||
sleep 3
|
||||
done
|
||||
|
||||
# Upload files
|
||||
./uploadToProvider.sh
|
||||
|
||||
|
|
|
|||
25
docs/scripts/setupValidationService.sh
Executable file
25
docs/scripts/setupValidationService.sh
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
sudo mkdir -p /var/lib/csaf
|
||||
sudo chgrp www-data /var/lib/csaf/
|
||||
sudo chmod g+s /var/lib/csaf/
|
||||
sudo touch /var/lib/csaf/validations.db
|
||||
sudo chgrp www-data /var/lib/csaf/validations.db
|
||||
sudo chmod g+rw,o-rwx /var/lib/csaf/validations.db
|
||||
|
||||
echo '
|
||||
remote_validator= { "url" = "http://localhost:3000", "presets" = ["mandatory"], "cache" = "/var/lib/csaf/validations.db" }
|
||||
' | sudo tee --append /usr/lib/csaf/config.toml
|
||||
|
||||
# Install nodejs
|
||||
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
|
||||
sudo apt-get install -y nodejs
|
||||
|
||||
npm install pm2 -g
|
||||
|
||||
pushd ~
|
||||
git clone https://github.com/secvisogram/csaf-validator-service.git
|
||||
cd csaf-validator-service
|
||||
npm ci
|
||||
pm2 start npm -- run dev
|
||||
popd
|
||||
Loading…
Add table
Add a link
Reference in a new issue