<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ct-sans/internal/chunk, branch v0.0.2</title>
<subtitle>Research tool collecting SANs from CT logs</subtitle>
<id>https://git.rgdd.se/ct-sans/atom?h=v0.0.2</id>
<link rel='self' href='https://git.rgdd.se/ct-sans/atom?h=v0.0.2'/>
<link rel='alternate' type='text/html' href='https://git.rgdd.se/ct-sans/'/>
<updated>2023-03-23T10:58:16+00:00</updated>
<entry>
<title>Automate handling of notice file</title>
<updated>2023-03-23T10:58:16+00:00</updated>
<author>
<name>Rasmus Dahlberg</name>
<email>rasmus@rgdd.se</email>
</author>
<published>2023-03-23T10:09:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rgdd.se/ct-sans/commit/?id=ad9fb49670e28414637761bac4b8e8940e2d6770'/>
<id>urn:sha1:ad9fb49670e28414637761bac4b8e8940e2d6770</id>
<content type='text'>
Here's a hacky tool to migrate our ongoing v0.0.1 measurement once it's
done.  I.e., just split-up the NOTICE prints we have in collect.stdout,
putting them in per-log notice files that happens automatically now.

```
// Package main provides a hacky tool that extracts NOTICE: &lt;log desc&gt; prints
// from a file collect.stdout, putting them in the logs data directories as
// notice.txt.  Only meant to migrate away from v0.0.1 that did not store
// per-log notice files automatically, which makes things less error-prone.
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	logger "log"
	"os"
	"strings"

	"gitlab.torproject.org/rgdd/ct/pkg/metadata"
)

func main() {
	directory := "../data"
	logDirectory := fmt.Sprintf("%s/logs", directory)
	noticeFile := "../collect.stdout"

	b, err := os.ReadFile(fmt.Sprintf("%s/metadata.json", directory))
	if err != nil {
		logger.Fatal(err)
	}
	var md metadata.Metadata
	if err := json.Unmarshal(b, &amp;md); err != nil {
		logger.Fatal(err)
	}
	if b, err = os.ReadFile(noticeFile); err != nil {
		logger.Fatal(err)
	}

	lines := bytes.Split(b, []byte("\n"))
	for _, log := range logs(md) {
		id, _ := log.Key.ID()
		desc := *log.Description

		var notes []byte
		var numNotes int
		for _, line := range lines[:len(lines)-1] {
			if strings.Contains(string(line), fmt.Sprintf("NOTICE: %s", desc)) {
				notes = append(notes, line...)
				notes = append(notes, []byte("\n")...)
				numNotes += 1
			}
		}

		if len(notes) == 0 {
			logger.Printf("%s: no notices", desc)
			continue
		}

		logger.Printf("%s: %d notices", desc, numNotes)
		if err := os.WriteFile(fmt.Sprintf("%s/%x/notice.txt", logDirectory, id[:]), notes, 0644); err != nil {
			logger.Fatal(err)
		}
	}
}

func logs(md metadata.Metadata) (logs []metadata.Log) {
	for _, operators := range md.Operators {
		for _, log := range operators.Logs {
			if log.Description == nil {
				logger.Printf("WARNING: skipping log without description")
				continue
			}
			if log.State == nil {
				continue // skip logs with unknown states
			}
			if log.State.Name == metadata.LogStatePending {
				continue // pending logs do not count towards CT-compliance
			}
			if log.State.Name == metadata.LogStateRetired {
				continue // retired logs are not necessarily reachable
			}
			if log.State.Name == metadata.LogStateRejected {
				continue // rejected logs do not count towards CT-compliance
			}

			logs = append(logs, log)
		}
	}
	return
}
```
</content>
</entry>
<entry>
<title>add credit</title>
<updated>2023-03-18T12:22:04+00:00</updated>
<author>
<name>Rasmus Dahlberg</name>
<email>rasmus@rgdd.se</email>
</author>
<published>2023-03-18T12:22:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rgdd.se/ct-sans/commit/?id=1cef99047c49ed29f248161c5b06b15c80665e48'/>
<id>urn:sha1:1cef99047c49ed29f248161c5b06b15c80665e48</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add heap chunk and helpers</title>
<updated>2023-03-17T09:42:57+00:00</updated>
<author>
<name>Rasmus Dahlberg</name>
<email>rasmus@rgdd.se</email>
</author>
<published>2023-03-17T09:42:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.rgdd.se/ct-sans/commit/?id=979e87fcce5482d6da1dd40b3e5ba790dc7af7ea'/>
<id>urn:sha1:979e87fcce5482d6da1dd40b3e5ba790dc7af7ea</id>
<content type='text'>
</content>
</entry>
</feed>
