Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/pull_request_templates/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Pull Request

## Description
<!-- A brief description of the changes and the problem they solve. -->

## Related Issues
<!-- List any related issues or tickets (e.g., "Fixes #123"). -->

## Type of Change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update

## Testing
- [ ] I have added/updated tests for the changes.
- [ ] All tests pass locally with my changes.
- [ ] I have tested the changes in the following environments:
- [ ] Local development
- [ ] Staging
- [ ] Production (if applicable)

## Documentation
- [ ] I have updated the documentation to reflect the changes.
- [ ] The changes are documented in the README or relevant documentation files.

## Additional Notes
<!-- Any additional notes or context for the reviewers. -->
43 changes: 31 additions & 12 deletions .github/workflows/scans_ci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
name:
on: [push, pull_request, create, delete, issue_comment]
name: CI/CD Pipeline

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
schedule:
- cron: '0 0 * * 0' # Weekly run on Sunday at midnight

jobs:
build:
test:
name: Test on Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x] # Test on multiple Node.js versions
Comment on lines +15 to +17

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Update the Node.js matrix to supported LTS versions to avoid running CI on EOL runtimes.

12.x and 14.x are end-of-life and no longer receive security updates. Unless you specifically need to support them, consider updating the matrix to current LTS versions (e.g., 18.x and 20.x) so CI aligns with supported production runtimes and future dependency support.

Suggested change
strategy:
matrix:
node-version: [12.x, 14.x, 16.x] # Test on multiple Node.js versions
strategy:
matrix:
node-version: [18.x, 20.x] # Test on supported LTS Node.js versions

steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: '12.x'
- uses: codespell-project/actions-codespell@master
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Check for common typos
uses: khulnasoft/codetypo-actions@master
with:
check_filenames: true
skip: ./.github/*,.git,./package.json,./package-lock.json,./node_modules,./tests,./config,*.png,Dockerfile,./scripts,*.spec.js,./plugins/azure/storageaccounts/storageAccountsAADEnabled.js,./plugins/aws/cloudtrail/cloudtrailBucketAccessLogging.js,./helpers/google/index.js,*zip
ignore_words_list: iam,\"tRe\",AKS,aks,optin,callInt,callInt
- run: npm install


- name: Install Dependencies
run: npm ci

- name: Lint
run: npm run lint

- name: NPM Test
- name: Run Tests
run: npm test

- name: Build
run: npm run build --if-present
Comment on lines +43 to +44

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (performance): Consider moving the build step to a separate job to avoid redundant builds on every matrix entry.

Because Build runs for every matrix Node.js version, it unnecessarily multiplies build time and resource usage. If your build artifacts are runtime-agnostic, consider running npm run build --if-present in a separate job that executes once (e.g., on a single LTS Node version) after tests complete. This preserves multi-runtime test coverage while making the workflow faster and more efficient.

Suggested implementation:

      - name: Run Tests
        run: npm test

To complete the change, you should also:

  1. Add a new job (e.g., build) under the top-level jobs: section that:
    • Uses a single Node.js version (typically the current LTS, e.g., 20.x).
    • Depends on the matrix test job via needs: <test-job-id> so it only runs once after tests succeed.
    • Checks out the code, sets up Node with the chosen version, runs npm ci, and then npm run build --if-present.

For example (you will need to adjust needs: to match your existing job id, and align indentation with your file):

jobs:
  # existing test/matrix job
  tests:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [18.x, 20.x]
    steps:
      # ... checkout, setup-node, npm ci, lint, test (no build here)

  build:
    needs: tests          # make sure this matches the actual test job id
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Use Node.js LTS
        uses: actions/setup-node@v4
        with:
          node-version: 20.x

      - name: Install dependencies
        run: npm ci

      - name: Build
        run: npm run build --if-present

Ensure that:

  • The new build job is at the same indentation level as your existing job(s) under jobs:.
  • The needs: value references the correct existing job id (e.g., tests, ci, or whatever your current matrix job is named).

56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,65 @@ A commercial version of CloudExploit hosted at Khulnasoft Wave. Try [Khulnasoft
## Installation
Ensure that NodeJS is installed. If not, install it from [here](https://nodejs.org/download/).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (typo): Consider using the canonical spelling "Node.js" instead of "NodeJS".

To match the official project name and common usage, please change "NodeJS" to "Node.js" here (e.g., "Ensure that Node.js is installed.").

Suggested change
Ensure that NodeJS is installed. If not, install it from [here](https://nodejs.org/download/).
Ensure that Node.js is installed. If not, install it from [here](https://nodejs.org/download/).


```
```bash
$ git clone git@github.com:cloudexploit/scans.git
$ npm install
```

## Development and Testing

### Running Tests

To run the test suite, use the following command:

```bash
npm test
```

### Running Specific Tests

To run a specific test file or test suite, you can use the following command:

```bash
npm test -- <path-to-test-file>
```

### Test Coverage

To generate a test coverage report, run:

```bash
npm run test:coverage
```

### Linting

To check for code style issues, run:

```bash
npm run lint
```

### CI/CD

The project uses GitHub Actions for continuous integration. The following workflows are defined:

- **CI Pipeline**: Runs on every push and pull request to the `main` or `master` branch. It includes:
- Linting
- Unit tests across multiple Node.js versions (12.x, 14.x, 16.x)
- Build verification

### Pull Requests

When submitting a pull request, please ensure that:

1. All tests pass
2. The code is properly linted
3. New features include appropriate tests
4. Documentation is updated if necessary

Use the provided pull request template to ensure consistency in code reviews.

## Configuration
CloudExploit requires read-only permission to your cloud account. Follow the guides below to provision this access:

Expand Down
2 changes: 1 addition & 1 deletion plugins/aws/eks/eksKubernetesVersion.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('eksKubernetesVersion', function () {
"cluster": {
"name": "mycluster",
"arn": "arn:aws:eks:us-east-1:012345678911:cluster/mycluster",
"version": "1.29",
"version": "1.30",
}
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const webhooks = [
"id": "/subscriptions/12345/resourceGroups/test-rg/providers/Microsoft.Automation/automationAccounts/test-automationacct/webhooks/test1",
"name": "test1",
"creationTime": "2024-01-22T13:33:52.1066667+00:00",
"expiryTime": "2025-01-22T13:33:52.1066667+00:00",
// Set expiry to 1 year from now to ensure it's in the future
"expiryTime": new Date(Date.now() + 365 * 24 * 60 * 60 * 1000).toISOString(),
},
{
"id": "/subscriptions/12345/resourceGroups/test-rg/providers/Microsoft.Automation/automationAccounts/test-automationacct/webhooks/test2",
Expand Down
Loading