Skip to content

Commit

Permalink
Update InSpec Object (ts-inspec-objects) import (#3230)
Browse files Browse the repository at this point in the history
* Update InSpec Object (ts-inspec-objects) import

Update the InSpec Object (ts-inspec-objects) to the new release version 2.0.0

* updated @mitre/inspec-objects to the latest version, 2.0.1

Signed-off-by: George M Dias <[email protected]>

* updates after merging with main

Signed-off-by: George M Dias <[email protected]>

---------

Signed-off-by: George M Dias <[email protected]>
  • Loading branch information
georgedias authored Jan 27, 2025
1 parent f91963b commit a8e21b5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 35 deletions.
9 changes: 4 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@mitre/emass_client": "3.10.0",
"@mitre/hdf-converters": "2.11.1",
"@mitre/heimdall-lite": "2.11.1",
"@mitre/inspec-objects": "2.0.0",
"@mitre/inspec-objects": "2.0.1",
"@oclif/core": "^4.0.15",
"@oclif/plugin-help": "^6.0.9",
"@oclif/plugin-plugins": "^5.0.14",
Expand Down
8 changes: 2 additions & 6 deletions src/commands/generate/delta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ import {
updateProfileUsingXCCDF,
processXCCDF,
updateControl,
Profile,
Control,
} from '@mitre/inspec-objects'

// eslint-disable-next-line no-warning-comments
// TODO: We shouldn't have to import like this, open issue to clean library up for inspec-objects
// test failed in updating inspec-objects to address high lvl vuln
import Profile from '@mitre/inspec-objects/lib/objects/profile'
import Control from '@mitre/inspec-objects/lib/objects/control'
import path from 'path'
import {createWinstonLogger} from '../../utils/logging'
import fse from 'fs-extra'
Expand Down
24 changes: 2 additions & 22 deletions src/commands/generate/inspec_profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import parser from 'fast-xml-parser'
import {InSpecMetaData, InspecReadme} from '../../types/inspec'
import path from 'path'
import {createWinstonLogger} from '../../utils/logging'
import {processOVAL, processXCCDF} from '@mitre/inspec-objects'
import Profile from '@mitre/inspec-objects/lib/objects/profile'
import {processOVAL, processXCCDF, Profile} from '@mitre/inspec-objects'
import {BaseCommand} from '../../utils/oclif/baseCommand'
import {Logger} from 'winston'
import _ from 'lodash'
import YAML from 'yaml'

export default class InspecProfile extends BaseCommand<typeof InspecProfile> {
static readonly usage =
Expand Down Expand Up @@ -629,25 +627,7 @@ ${contentObj.profileType === 'CIS' ?
}

function generateYaml(profile: Profile, outDir: string, logger: Logger) {
// ----------------------------------------------------------------------
// NOTE: Not using the profile.createInspecYaml() as it does not wrap the
// inspect_version in double quotes (the format is ~>#.#). Use this
// function until ts-object.ts method is fixed

const inspecYmlContent = YAML.stringify({
name: profile.name,
title: profile.title,
maintainer: profile.maintainer,
copyright: profile.copyright,
copyright_email: profile.copyright_email,
license: profile.license,
summary: profile.summary,
description: profile.description,
version: profile.version,
supports: profile.supports,
depends: profile.depends,
inspec_version: YAML.stringify(`${profile.inspec_version}`, {defaultStringType: 'QUOTE_DOUBLE'}),
}) +
const inspecYmlContent = profile.createInspecYaml() +
`
### INPUTS ###
Expand Down
2 changes: 1 addition & 1 deletion src/commands/generate/update_controls4delta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {readdir} from 'fs/promises'
import {execSync} from 'child_process'
import {Flags} from '@oclif/core'
import {createWinstonLogger} from '../../utils/logging'
import Profile from '@mitre/inspec-objects/lib/objects/profile'
import {
getExistingDescribeFromControl,
processInSpecProfile,
processXCCDF,
Profile,
} from '@mitre/inspec-objects'
import colors from 'colors' // eslint-disable-line no-restricted-imports
import {BaseCommand} from '../../utils/oclif/baseCommand'
Expand Down

0 comments on commit a8e21b5

Please sign in to comment.