forked from engineering/cloudservices
Merge branch 'master' of https://gitlab.libraryofcode.org/engineering/cloudservices
commit
9a47286889
11
build.sh
11
build.sh
|
@ -1,6 +1,5 @@
|
||||||
echo "Library of Code sp-us | Cloud Services"
|
# This file builds the Go binaries. Hardcoded by LOC Engineering
|
||||||
echo "TypeScript & Go"
|
go build -o dist/bin/storage src/go/storage/storage.go src/go/storage/dirsize.go
|
||||||
echo "Building TS files"
|
file dist/bin/storage
|
||||||
yarn run build
|
go build -o dist/bin/checkCertificate src/go/checkCertificate/checkCertificate.go
|
||||||
echo "Building Go files"
|
file dist/bin/checkCertificate
|
||||||
go build -o dist/intervals/storage src/intervals/storage.go src/intervals/dirsize.go
|
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
import { Client } from '..';
|
||||||
|
|
||||||
|
export interface Certificate {
|
||||||
|
subject: {
|
||||||
|
commonName: string,
|
||||||
|
emailAddress: string
|
||||||
|
organizationName: string,
|
||||||
|
organizationalUnitName: string,
|
||||||
|
countryName: string,
|
||||||
|
},
|
||||||
|
issuer: {
|
||||||
|
commonName: string
|
||||||
|
emailAddress: null,
|
||||||
|
organizationName: string,
|
||||||
|
organizationalUnitName: string,
|
||||||
|
countryName: string,
|
||||||
|
},
|
||||||
|
extensions: {
|
||||||
|
keyUsage: '[ Not implemented by executable ]',
|
||||||
|
extendedKeyUsage: string[],
|
||||||
|
certificatePolicies: string[],
|
||||||
|
},
|
||||||
|
serial: string,
|
||||||
|
fingerPrint: string,
|
||||||
|
signatureAlgorithm: string,
|
||||||
|
publicKeyAlgorithm: string,
|
||||||
|
notBefore: Date,
|
||||||
|
notAfter: Date,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function parseCertificate(client: Client, pathToCertificate: string): Promise<Certificate> {
|
||||||
|
const result = await client.util.exec(`${__dirname}/../bin/checkCertificate ${pathToCertificate}`);
|
||||||
|
const parsedObject = JSON.parse(result);
|
||||||
|
return {
|
||||||
|
subject: {
|
||||||
|
commonName: parsedObject.RawParse.Subject.CommonName,
|
||||||
|
emailAddress: parsedObject.AbstractParse.EmailAddress,
|
||||||
|
organizationName: parsedObject.RawParse.Subject.Organization[0],
|
||||||
|
organizationalUnitName: parsedObject.RawParse.Subject.OrganizationalUnit[0],
|
||||||
|
countryName: parsedObject.RawParse.Subject.Country[0],
|
||||||
|
},
|
||||||
|
issuer: {
|
||||||
|
commonName: parsedObject.RawParse.Issuer.CommonName,
|
||||||
|
emailAddress: null,
|
||||||
|
organizationName: parsedObject.RawParse.Issuer.Organization[0],
|
||||||
|
organizationalUnitName: parsedObject.RawParse.Issuer.OrganizationalUnit[0],
|
||||||
|
countryName: parsedObject.RawParse.Issuer.Country[0],
|
||||||
|
},
|
||||||
|
extensions: {
|
||||||
|
keyUsage: '[ Not implemented by executable ]',
|
||||||
|
extendedKeyUsage: parsedObject.AbstractParse.ExtendedKeyUsage,
|
||||||
|
certificatePolicies: parsedObject.AbstractParse.PolicyIdentifiers,
|
||||||
|
},
|
||||||
|
serial: parsedObject.AbstractParse.SerialNumber,
|
||||||
|
fingerPrint: parsedObject.AbstractParse.FingerPrint,
|
||||||
|
signatureAlgorithm: parsedObject.AbstractParse.SignatureAlgorithm,
|
||||||
|
publicKeyAlgorithm: parsedObject.AbstractParse.PublicKeyAlgorithm,
|
||||||
|
notBefore: new Date(parsedObject.RawParse.NotBefore),
|
||||||
|
notAfter: new Date(parsedObject.RawParse.NotAfter),
|
||||||
|
};
|
||||||
|
}
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"time"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Collection the MongoDB Account collection
|
// Collection the MongoDB Account collection
|
||||||
|
@ -39,6 +39,7 @@ func HandleError(e error, serv int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
var status bool
|
||||||
type Config struct {
|
type Config struct {
|
||||||
MongoDB string `json:"mongoURL"`
|
MongoDB string `json:"mongoURL"`
|
||||||
}
|
}
|
||||||
|
@ -67,15 +68,19 @@ func main() {
|
||||||
_, err = RedisClient.Ping().Result()
|
_, err = RedisClient.Ping().Result()
|
||||||
fmt.Printf("Connected to Redis [GO]\n")
|
fmt.Printf("Connected to Redis [GO]\n")
|
||||||
HandleError(err, 1)
|
HandleError(err, 1)
|
||||||
|
status = false
|
||||||
|
|
||||||
for {
|
for {
|
||||||
fmt.Printf("Calling handler func [GO]\n")
|
fmt.Printf("Calling handler func [GO]\n")
|
||||||
handler()
|
if status == false {
|
||||||
|
handler(&status)
|
||||||
time.Sleep(1000000 * time.Millisecond)
|
time.Sleep(1000000 * time.Millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func handler() {
|
func handler(status* bool) {
|
||||||
|
*status = true
|
||||||
cur, err := Collection.Find(context.TODO(), bson.D{})
|
cur, err := Collection.Find(context.TODO(), bson.D{})
|
||||||
HandleError(err, 0)
|
HandleError(err, 0)
|
||||||
|
|
||||||
|
@ -84,6 +89,7 @@ func handler() {
|
||||||
fmt.Printf("Checking account information for %s\n", cur.Current.Lookup("username").String())
|
fmt.Printf("Checking account information for %s\n", cur.Current.Lookup("username").String())
|
||||||
time.Sleep(600000 * time.Millisecond)
|
time.Sleep(600000 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
*status = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkAccountSizeAndUpdate(username string, id string) {
|
func checkAccountSizeAndUpdate(username string, id string) {
|
||||||
|
|
Loading…
Reference in New Issue