<commit_before>package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"log"
	"os/exec"
	"strconv"
	"strings"
)

type Cipher struct {
	// Name  string     `json:"name"`
	Proto string     `json:"proto"`
	Kx    string     `json:"kx"`
	Au    string     `json:"au"`
	Enc   Encryption `json:"encryption"`
	Mac   string     `json:"mac"`
}

type Encryption struct {
	Cipher string `json:"cipher"`
	Bits   int    `json:"key"`
}

var opensslpath = "openssl"

func main() {
	cmd := opensslpath + " ciphers -v"
	comm := exec.Command("bash", "-c", cmd)
	var out bytes.Buffer
	var stderr bytes.Buffer
	comm.Stdout = &out
	comm.Stderr = &stderr
	err := comm.Run()
	if err != nil {
		log.Println(err)
		return
	}

	ciphers := make(map[string]Cipher)

	lines := strings.Split(out.String(), "\n")
	for _, l := range lines {
		if l == "" {
			break
		}
		c := Cipher{}
		line := strings.Fields(l)
		c.Proto = line[1]
		c.Kx = strings.Split(line[2], "=")[1]
		c.Au = strings.Split(line[3], "=")[1]
		c.Enc.Cipher = strings.Split(strings.Split(line[4], "=")[1], "(")[0]
		c.Enc.Bits, _ = strconv.Atoi(strings.TrimRight(strings.Split(strings.Split(line[4], "=")[1], "(")[1], ")"))
		c.Mac = strings.Split(line[5], "=")[1]
		ciphers[line[0]] = c
	}
<commit_msg>run from ciherscan openssl binary<commit_after>package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"log"
	"os/exec"
	"strconv"
	"strings"
)

type Cipher struct {
	// Name  string     `json:"name"`
	Proto string     `json:"proto"`
	Kx    string     `json:"kx"`
	Au    string     `json:"au"`
	Enc   Encryption `json:"encryption"`
	Mac   string     `json:"mac"`
}

type Encryption struct {
	Cipher string `json:"cipher"`
	Bits   int    `json:"key"`
}

var opensslpath = "/opt/cipherscan/openssl"

func main() {
	cmd := opensslpath + " ciphers -v"
	comm := exec.Command("bash", "-c", cmd)
	var out bytes.Buffer
	var stderr bytes.Buffer
	comm.Stdout = &out
	comm.Stderr = &stderr
	err := comm.Run()
	if err != nil {
		log.Println(err)
		return
	}

	ciphers := make(map[string]Cipher)

	lines := strings.Split(out.String(), "\n")
	for _, l := range lines {
		if l == "" {
			break
		}
		line := strings.Fields(l)
		encbits, err := strconv.Atoi(strings.TrimRight(strings.Split(strings.Split(line[4], "=")[1], "(")[1], ")"))
		if err != nil {
			fmt.Errorf("Could not get encryption bits, %s", err)
			return
		}
		enc := Encryption{
			Cipher: strings.Split(strings.Split(line[4], "=")[1], "(")[0],
			Bits:   encbits,
		}
		c := Cipher{
			Proto: line[1],
			Kx:    strings.Split(line[2], "=")[1],
			Au:    strings.Split(line[3], "=")[1],
			Enc:   enc,
			Mac:   strings.Split(line[5], "=")[1],
		}
		ciphers[line[0]] = c
	}

{'fraction_non_alphanumeric': 0.1987369985141159, 'fraction_numerical': 0.010401188707280832, 'mean_word_length': 3.301916932907348, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6932893', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1080, 'n_words': 238}