<commit_before>package x509util

import (
	"crypto/x509"
	"encoding/asn1"
	"fmt"
	"github.com/Symantec/Dominator/lib/constants"
	"strings"
)

func getPermittedMethods(cert *x509.Certificate) (map[string]struct{}, error) {
	methodList := make(map[string]struct{})
	for _, extension := range cert.Extensions {
		if extension.Id.String() != constants.PermittedMethodListOID {
			continue
		}
		var lines []string
		rest, err := asn1.Unmarshal(extension.Value, &lines)
		if err != nil {
			return nil, err
		}
		if len(rest) > 0 {
			return nil, fmt.Errorf("%d extra bytes in method extension",
				len(rest))
		}
		for _, sm := range lines {
			if strings.Count(sm, ".") == 1 {
				methodList[sm] = struct{}{}
			} else {
				return nil, fmt.Errorf("bad line: \"%s\"", sm)
			}
		}
		return methodList, nil
	}
	// Fallback to deprecated location.
	for _, sm := range strings.Split(cert.Subject.CommonName, ",") {
		if strings.Count(sm, ".") == 1 {
			methodList[sm] = struct{}{}
		}
	}
	return methodList, nil
}<commit_msg>Remove deprecated methods encoding in lib/x509util.GetPermittedMethods().<commit_after>package x509util

import (
	"crypto/x509"
	"encoding/asn1"
	"fmt"
	"github.com/Symantec/Dominator/lib/constants"
	"strings"
)

func getPermittedMethods(cert *x509.Certificate) (map[string]struct{}, error) {
	methodList := make(map[string]struct{})
	for _, extension := range cert.Extensions {
		if extension.Id.String() != constants.PermittedMethodListOID {
			continue
		}
		var lines []string
		rest, err := asn1.Unmarshal(extension.Value, &lines)
		if err != nil {
			return nil, err
		}
		if len(rest) > 0 {
			return nil, fmt.Errorf("%d extra bytes in method extension",
				len(rest))
		}
		for _, sm := range lines {
			if strings.Count(sm, ".") == 1 {
				methodList[sm] = struct{}{}
			} else {
				return nil, fmt.Errorf("bad line: \"%s\"", sm)
			}
		}
		return methodList, nil
	}
	return methodList, nil
}
{'fraction_non_alphanumeric': 0.1548856548856549, 'fraction_numerical': 0.015592515592515593, 'mean_word_length': 3.63855421686747, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6066419', 'n_tokens_mistral': 760, 'n_tokens_neox': 669, 'n_words': 158}