Skip to content

Commit 95911df

Browse files
authored
Merge pull request #104 from isimluk/ci-scap
Attempt to fix SCAP CI
2 parents 505fa2d + a727541 commit 95911df

File tree

10 files changed

+23
-55
lines changed

10 files changed

+23
-55
lines changed

.github/workflows/scap.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ workdir=./scap/
99
mkdir -p $workdir
1010
cat <<__END__ > $workdir/go.mod
1111
module github.com/gocomply/scap
12-
go 1.17
12+
go 1.20
1313
__END__
1414

1515
pushd $workdir
@@ -22,6 +22,7 @@ pushd $workdir
2222

2323
# Generage go code based on XSDs
2424
$xsd2go convert .scap_schemas/schemas/cpe/2.3/cpe-dictionary_2.3.xsd github.com/gocomply/scap pkg/scap/models
25+
go vet ./...
2526
$xsd2go convert \
2627
--xmlns-override=http://cpe.mitre.org/language/2.0=cpe_language \
2728
.scap_schemas/schemas/xccdf/1.2/xccdf_1.2.xsd github.com/gocomply/scap pkg/scap/models

pkg/template/pkged.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/template/types.tmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ import (
4545
{{- if .ContainsText }}
4646
Text string `xml:",chardata"`
4747
{{- end}}
48-
innerXml string `xml:",innerxml"`
48+
{{- if .ContainsInnerXml }}
49+
InnerXml string `xml:",innerxml"`
50+
{{- end}}
4951
}
5052
{{end}}
5153

pkg/xsd/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ func (ct *ComplexType) GoTypeName() string {
9292
return ct.GoName()
9393
}
9494

95+
func (ct *ComplexType) ContainsInnerXml() bool {
96+
return ct.Mixed
97+
}
98+
9599
func (ct *ComplexType) ContainsText() bool {
96100
return ct.content != nil && ct.content.ContainsText()
97101
}

tests/smoke_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package tests
22

33
import (
44
"fmt"
5-
"io/ioutil"
65
"os"
76
"os/exec"
87
"path/filepath"
@@ -21,14 +20,14 @@ func TestSanity(t *testing.T) {
2120
for _, xsdPath := range xsdFiles {
2221
actual := assertConvertsFine(t, xsdPath)
2322

24-
expected, err := ioutil.ReadFile(xsdPath + ".out")
23+
expected, err := os.ReadFile(xsdPath + ".out")
2524
require.NoError(t, err)
2625
assert.Equal(t, string(expected), string(actual))
2726
}
2827
}
2928

3029
func assertConvertsFine(t *testing.T, xsdPath string) []byte {
31-
dname, err := ioutil.TempDir("", "xsd2go_tests_")
30+
dname, err := os.MkdirTemp("", "xsd2go_tests_")
3231
assert.Nil(t, err)
3332
defer os.RemoveAll(dname)
3433

@@ -41,7 +40,7 @@ func assertConvertsFine(t *testing.T, xsdPath string) []byte {
4140

4241
generatedFilePath, err := locateGeneratedFile(outputDir)
4342
require.NoError(t, err)
44-
result, err := ioutil.ReadFile(generatedFilePath)
43+
result, err := os.ReadFile(generatedFilePath)
4544
require.NoError(t, err)
4645

4746
out, err := exec.Command("go", "build", generatedFilePath).Output()

tests/xsd-examples/valid/complex.xsd.out

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ type MyElementType struct {
3535
Id21 *int `xml:"id_21"`
3636

3737
Id22 *int `xml:"id_22"`
38-
39-
innerXml string `xml:",innerxml"`
4038
}
4139

4240
// XSD SimpleType declarations

tests/xsd-examples/valid/restriction.xsd.out

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ type StateRefType struct {
2121
XMLName xml.Name
2222

2323
StateRef StateIdpattern `xml:"state_ref,attr"`
24-
25-
innerXml string `xml:",innerxml"`
2624
}
2725

2826
type MySimpleBaseType struct {
@@ -32,8 +30,7 @@ type MySimpleBaseType struct {
3230

3331
Operation OperationEnumeration `xml:"operation,attr,omitempty"`
3432

35-
Text string `xml:",chardata"`
36-
innerXml string `xml:",innerxml"`
33+
Text string `xml:",chardata"`
3734
}
3835

3936
type MyElementType struct {
@@ -42,8 +39,6 @@ type MyElementType struct {
4239
Datatype DatatypeEnumeration `xml:"datatype,attr,omitempty"`
4340

4441
Operation OperationEnumeration `xml:"operation,attr,omitempty"`
45-
46-
innerXml string `xml:",innerxml"`
4742
}
4843

4944
// XSD SimpleType declarations

tests/xsd-examples/valid/simple-8859-1.xsd.out

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ type MyElementType struct {
1919
XMLName xml.Name
2020

2121
Id int64 `xml:",any"`
22-
23-
innerXml string `xml:",innerxml"`
2422
}
2523

2624
// XSD SimpleType declarations

tests/xsd-examples/valid/simple.xsd.out

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ type MyElementType struct {
1919
XMLName xml.Name
2020

2121
Id int64 `xml:",any"`
22-
23-
innerXml string `xml:",innerxml"`
2422
}
2523

2624
// XSD SimpleType declarations

tests/xsd-examples/valid/xmldsig-core-schema.xsd.out

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -264,17 +264,14 @@ type SignatureType struct {
264264
KeyInfo *KeyInfoType `xml:"KeyInfo"`
265265

266266
Object []ObjectType `xml:"Object"`
267-
268-
innerXml string `xml:",innerxml"`
269267
}
270268

271269
type SignatureValueType struct {
272270
XMLName xml.Name
273271

274272
Id string `xml:"Id,attr,omitempty"`
275273

276-
Text string `xml:",chardata"`
277-
innerXml string `xml:",innerxml"`
274+
Text string `xml:",chardata"`
278275
}
279276

280277
type SignedInfoType struct {
@@ -287,16 +284,14 @@ type SignedInfoType struct {
287284
SignatureMethod SignatureMethodType `xml:"SignatureMethod"`
288285

289286
Reference []ReferenceType `xml:"Reference"`
290-
291-
innerXml string `xml:",innerxml"`
292287
}
293288

294289
type CanonicalizationMethodType struct {
295290
XMLName xml.Name
296291

297292
Algorithm string `xml:"Algorithm,attr"`
298293

299-
innerXml string `xml:",innerxml"`
294+
InnerXml string `xml:",innerxml"`
300295
}
301296

302297
type SignatureMethodType struct {
@@ -306,7 +301,7 @@ type SignatureMethodType struct {
306301

307302
HmacoutputLength *HmacoutputLengthType `xml:",any"`
308303

309-
innerXml string `xml:",innerxml"`
304+
InnerXml string `xml:",innerxml"`
310305
}
311306

312307
type ReferenceType struct {
@@ -323,16 +318,12 @@ type ReferenceType struct {
323318
DigestMethod DigestMethodType `xml:"DigestMethod"`
324319

325320
DigestValue DigestValueType `xml:"DigestValue"`
326-
327-
innerXml string `xml:",innerxml"`
328321
}
329322

330323
type TransformsType struct {
331324
XMLName xml.Name
332325

333326
Transform []TransformType `xml:",any"`
334-
335-
innerXml string `xml:",innerxml"`
336327
}
337328

338329
type TransformType struct {
@@ -342,15 +333,15 @@ type TransformType struct {
342333

343334
Xpath []string `xml:"XPath"`
344335

345-
innerXml string `xml:",innerxml"`
336+
InnerXml string `xml:",innerxml"`
346337
}
347338

348339
type DigestMethodType struct {
349340
XMLName xml.Name
350341

351342
Algorithm string `xml:"Algorithm,attr"`
352343

353-
innerXml string `xml:",innerxml"`
344+
InnerXml string `xml:",innerxml"`
354345
}
355346

356347
type KeyInfoType struct {
@@ -372,7 +363,7 @@ type KeyInfoType struct {
372363

373364
MgmtData []string `xml:"MgmtData"`
374365

375-
innerXml string `xml:",innerxml"`
366+
InnerXml string `xml:",innerxml"`
376367
}
377368

378369
type KeyValueType struct {
@@ -382,7 +373,7 @@ type KeyValueType struct {
382373

383374
RsakeyValue *RsakeyValueType `xml:"RSAKeyValue"`
384375

385-
innerXml string `xml:",innerxml"`
376+
InnerXml string `xml:",innerxml"`
386377
}
387378

388379
type RetrievalMethodType struct {
@@ -393,8 +384,6 @@ type RetrievalMethodType struct {
393384
Type string `xml:"Type,attr,omitempty"`
394385

395386
Transforms *TransformsType `xml:",any"`
396-
397-
innerXml string `xml:",innerxml"`
398387
}
399388

400389
type X509DataType struct {
@@ -409,8 +398,6 @@ type X509DataType struct {
409398
X509Certificate string `xml:"X509Certificate"`
410399

411400
X509Crl string `xml:"X509CRL"`
412-
413-
innerXml string `xml:",innerxml"`
414401
}
415402

416403
type X509IssuerSerialType struct {
@@ -419,8 +406,6 @@ type X509IssuerSerialType struct {
419406
X509IssuerName string `xml:"X509IssuerName"`
420407

421408
X509SerialNumber int64 `xml:"X509SerialNumber"`
422-
423-
innerXml string `xml:",innerxml"`
424409
}
425410

426411
type PgpdataType struct {
@@ -429,16 +414,12 @@ type PgpdataType struct {
429414
PgpkeyId string `xml:"PGPKeyID"`
430415

431416
PgpkeyPacket string `xml:"PGPKeyPacket"`
432-
433-
innerXml string `xml:",innerxml"`
434417
}
435418

436419
type SpkidataType struct {
437420
XMLName xml.Name
438421

439422
Spkisexp string `xml:",any"`
440-
441-
innerXml string `xml:",innerxml"`
442423
}
443424

444425
type ObjectType struct {
@@ -450,7 +431,7 @@ type ObjectType struct {
450431

451432
Encoding string `xml:"Encoding,attr,omitempty"`
452433

453-
innerXml string `xml:",innerxml"`
434+
InnerXml string `xml:",innerxml"`
454435
}
455436

456437
type ManifestType struct {
@@ -459,8 +440,6 @@ type ManifestType struct {
459440
Id string `xml:"Id,attr,omitempty"`
460441

461442
Reference []ReferenceType `xml:",any"`
462-
463-
innerXml string `xml:",innerxml"`
464443
}
465444

466445
type SignaturePropertiesType struct {
@@ -469,8 +448,6 @@ type SignaturePropertiesType struct {
469448
Id string `xml:"Id,attr,omitempty"`
470449

471450
SignatureProperty []SignaturePropertyType `xml:",any"`
472-
473-
innerXml string `xml:",innerxml"`
474451
}
475452

476453
type SignaturePropertyType struct {
@@ -480,7 +457,7 @@ type SignaturePropertyType struct {
480457

481458
Id string `xml:"Id,attr,omitempty"`
482459

483-
innerXml string `xml:",innerxml"`
460+
InnerXml string `xml:",innerxml"`
484461
}
485462

486463
type DsakeyValueType struct {
@@ -491,8 +468,6 @@ type DsakeyValueType struct {
491468
Y CryptoBinary `xml:"Y"`
492469

493470
J *CryptoBinary `xml:"J"`
494-
495-
innerXml string `xml:",innerxml"`
496471
}
497472

498473
type RsakeyValueType struct {
@@ -501,8 +476,6 @@ type RsakeyValueType struct {
501476
Modulus CryptoBinary `xml:"Modulus"`
502477

503478
Exponent CryptoBinary `xml:"Exponent"`
504-
505-
innerXml string `xml:",innerxml"`
506479
}
507480

508481
// XSD SimpleType declarations

0 commit comments

Comments
 (0)