mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
* Factor JSON evaluation and construction base URLs out of of checker. * Move json path matching to util. * Add csaf_aggregator (as additional command) * Improve itest workflow to checkout the branch where it is running on. resolve #105 resolve #72 Co-authored-by: tschmidtb51 <65305130+tschmidtb51@users.noreply.github.com> Co-authored-by: Bernhard Reiter <bernhard@intevation.de> Co-authored-by: Fadi Abbud <fadi.abbud@intevation.de>
38 lines
998 B
Go
38 lines
998 B
Go
// This file is Free Software under the MIT License
|
|
// without warranty, see README.md and LICENSES/MIT.txt for details.
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
//
|
|
// 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
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
// writeHash writes a hash to file.
|
|
func writeHash(fname, name string, hash []byte) error {
|
|
f, err := os.Create(fname)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Fprintf(f, "%x %s\n", hash, name)
|
|
return f.Close()
|
|
}
|
|
|
|
// writeFileHashes writes a file and its hashes to files.
|
|
func writeFileHashes(fname, name string, data, s256, s512 []byte) error {
|
|
// Write the file itself.
|
|
if err := os.WriteFile(fname, data, 0644); err != nil {
|
|
return err
|
|
}
|
|
// Write SHA256 sum.
|
|
if err := writeHash(fname+".sha256", name, s256); err != nil {
|
|
return err
|
|
}
|
|
// Write SHA512 sum.
|
|
return writeHash(fname+".sha512", name, s512)
|
|
}
|