Posts

Showing posts from December, 2021

gitlab linux grep fail if found

Background During the log4j vulnerability the need to stop deployments so verification of remediation was complete, therefore, the need to grep a files output of our security scan was needed.  The use of trivy was being used in scanning the docker containers for vulnerabilities.  Another line was simply added to grep for the CVE and exit 1 if found Gitlab Pipelines Content   trivy --exit-code 0 --cache-dir .trivycache/ --no-progress --severity $TRIVY_SEVERITY --vuln-type os,library -i images/\$DT_DEPLOYABLE.tar >> \$DT_DEPLOYABLE.scan.txt   if [ $(grep -c CVE-2021-44228 *.scan.txt) -ne 0 ]; then exit 1; fi

Java JPA

Definition The Java ORM standard for storing, accessing, and managing Java objects in a relational database Usage Scenario To abstract the database communication layer away from the developer, allowing to easily switch the database store vendor About Definition of the Storage Object Annotation on the Class @Entity @Table(name = "group", uniqueConstraints={@UniqueConstraint(columnNames={"groupname"})}) Annotation on the Fields @Id @Column(name = "id") @GeneratedValue(strategy = GenerationType.AUTO, generator = "group_seq_gen") @SequenceGenerator(name = "group_seq_gen", sequenceName = "group_id_seq", allocationSize = 1) @Column(name = "name", length = 64, insertable=true, updatable=false, unique=true) private String groupname;   Object Store Logic Inject EntityManager for use @PersistenceContext(unitName = "group-service-ds") private EntityManager entityManager; Create / Update / Delete public Group create(G...

Golang channels

Definition Channels  are the pipes that connect concurrent goroutines. You can send values into channels from one goroutine and receive those values into another goroutine. Usage Scenario To download multiple files from a server, you can use go routines to asynchronously run an algorithm to download a file, while the channel tells that algorithm what file to download. About Creation Sizing a Channel unlimited ,  but blocking on writing if nothing is listening on other end books := make ( chan string ) limited , blocks writing when channel is full books := make ( chan string , size int ) Writing <- on the right side of the channel is to send the content on the right into the channel *note: since messages sized to unlimited, it will block unless something is reading from the channel, therefore, use of Go-routine is used to asynchronously run that block books := make ( chan string ) go func () { books <- " black lagoon " }() Reading <- on the left side...