Skip to content

Commit

Permalink
Merge pull request #2 from polarityio/develop
Browse files Browse the repository at this point in the history
Initial release
  • Loading branch information
sarus committed Aug 15, 2023
2 parents b2a86ca + 09aa89c commit b94a4f4
Show file tree
Hide file tree
Showing 2,546 changed files with 179,521 additions and 4 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/release-current-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Release Current Version

on:
push:
branches: [ master, main ]

jobs:
Run:
uses: polarityio/polarity-github-actions/.github/workflows/release-server-versions-for-int-store.yml@master
# with:
# use-integration-development-checklist: false
23 changes: 23 additions & 0 deletions .github/workflows/run-int-dev-checklist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run Integration Development Checklist

on:
pull_request:
branches: [ master, main, develop ]

jobs:
run-integration-development-checklist:
runs-on: ubuntu-latest
container: 'centos:7'

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- name: Test NPM Install
id: test-npm-install
run: |
npm ci
- name: Polarity Integration Development Checklist
id: int-dev-checklist
uses: polarityio/polarity-integration-development-checklist@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Ignore Maven Compiled Project Files
*/target/

# Ignore IntelliJ Project Information
*.iml
.idea/

# Ignore Sublime Text Project Files
*.sublime-project
*.sublime-workspace
sftp-config.json

# Ignore Eclipse Project Information
*.settings
*.project
*.classpath
dependency-reduced-pom.xml

# Ignore Excel Files
*.xlsx

# Ignore local log files
*.log
*.remote-sync.json


# Ignore Generated HTML README Files
README.html

# Ignored installed NPM modules
node_modules/
test-runner.js
~
.polarity.conf
19 changes: 19 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"printWidth": 90,
"proseWrap": "preserve",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false,
"overrides": [
{
"files": "*.hbs",
"options": {
"singleQuote": false
}
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cSpell.words": ["exploitability"]
}
10 changes: 10 additions & 0 deletions .vscode/sftp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "nmap",
"host": "dev.polarity",
"protocol": "sftp",
"port": 22,
"username": "root",
"remotePath": "/app/polarity-server/integrations/nmap",
"uploadOnSave": true,
"password": "asdf"
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2020 Polarity.io, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
# Polarity NMAP Integration
# Polarity Nmap Integration

Nmap ("Network Mapper") is a free and open source utility for network discovery and security auditing.
Nmap ("Network Mapper") is a free and open source utility for network discovery and security auditing. When triggered by the user, the polarity Nmap integration runs an aggressive TCP Connect port-only scan on the specified IP address.

More specifically, the following scan is run on the specified IP address:

```
nmap -sT -T4 -Pn -top-ports 64 <ip address>
```

**Important** -- You must have the `nmap` utility installed on your Polarity Server for this integration to work. If you see the following error message then your Polarity Server does not have `nmap` installed:

```
/bin/sh: nmap: command not found
```

You can install `nmap` with the following command:

```bash
sudo yum install nmap
```

| <img src="./images/overlay.png" width=50%/> |
|---------------------------------------------|
| *Nmap Scan Example* |

### Top Ports

This setting controls how many ports will be scanned based on NMAP's built in port popularity"
This setting controls how many ports will be scanned based on NMAP's built-in port popularity"

### Private IPs Only

If checked, the integration will only scan private (RFC-1918) IP addresses.
If checked, the integration will only support scanning of private (RFC-1918) IP addresses.

## About Polarity

Expand Down
87 changes: 87 additions & 0 deletions components/block.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
polarity.export = PolarityComponent.extend({
details: Ember.computed.alias('block.data.details'),
entity: Ember.computed.alias('block.entity'),

init() {
let array = new Uint32Array(5);
this.set('uniqueIdPrefix', window.crypto.getRandomValues(array).join(''));

if (!this.get('block._state')) {
this.set('block._state', {});
this.set('block._state.isSubmitting', false);
this.set('block._state.conflictingRunning', false);
}
this._super(...arguments);
},
actions: {
submitUrl: function () {
this.scan();

this.set('block._state.errorMessage', '');
this.set('block._state.scanResult', '');
this.set('block._state.isSubmitting', true);
},
copyData: function () {
Ember.run.scheduleOnce(
'afterRender',
this,
this.copyElementToClipboard,
`nmap-container-${this.get('uniqueIdPrefix')}`
);

Ember.run.scheduleOnce('destroy', this, this.restoreCopyState);
}
},
copyElementToClipboard(element) {
window.getSelection().removeAllRanges();
let range = document.createRange();

range.selectNode(typeof element === 'string' ? document.getElementById(element) : element);
window.getSelection().addRange(range);
document.execCommand('copy');
window.getSelection().removeAllRanges();
},
restoreCopyState() {
this.set('showCopyMessage', true);

setTimeout(() => {
if (!this.isDestroyed) {
this.set('showCopyMessage', false);
}
}, 2000);
},
scan: function () {
this.set('block._state.scanResult', '');
this.set('block._state.errorMessage', '');

const payload = {
action: 'scan',
entity: this.get('block.entity.value')
};

this.sendIntegrationMessage(payload)
.then((response) => {
this.set('block._state.scanResult', response.reply);
})
.catch((err) => {
this.set('block._state.errorMessage', this.getErrorDetail(err));
})
.finally(() => {
this.set('block._state.isSubmitting', false);
});
},
getErrorDetail: (err) => {
if (err && err.meta && err.meta.detail) {
console.error(err.meta.detail);
if (typeof err.meta.detail === 'string') {
return err.meta.detail;
} else if (err.meta.detail.message && typeof err.meta.detail.message === 'string') {
return err.meta.detail.message;
} else {
return JSON.stringify(err.meta.detail.message, null, 2);
}
} else {
return JSON.stringify(err, null, 2);
}
}
});
47 changes: 47 additions & 0 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module.exports = {
name: 'NMAP',
acronym: 'NMAP',
description: 'Kick off an Nmap scan at the click of a button',
logging: {
level: 'info' //trace, debug, info, warn, error, fatal
},
styles: ['./styles/style.less'],
entityTypes: ['IPv4'],
block: {
component: {
file: './components/block.js'
},
template: {
file: './templates/block.hbs'
}
},
defaultColor: 'light-gray',
onDemandOnly: true,
request: {
cert: '',
key: '',
passphrase: '',
ca: '',
proxy: ''
},
options: [
{
key: 'topPorts',
name: 'Number of the Most Popular Ports to Scan',
description: "This setting controls how many ports will be scanned based on NMAP's built in port popularity",
default: 64,
type: 'number',
userCanEdit: false,
adminOnly: true
},
{
key: 'privateIpOnly',
name: 'Private IPs Only',
description: 'If checked, the integration will only be available for private (RFC-1918) IP addresses.',
default: false,
type: 'boolean',
userCanEdit: false,
adminOnly: true
}
]
};
52 changes: 52 additions & 0 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"polarityIntegrationUuid": "86a9fea0-3b0f-11ee-8581-77c3249c0c46",
"name": "NMAP",
"acronym": "NMAP",
"description": "Kick off an Nmap scan at the click of a button",
"logging": {
"level": "info"
},
"styles": [
"./styles/style.less"
],
"entityTypes": [
"IPv4"
],
"block": {
"component": {
"file": "./components/block.js"
},
"template": {
"file": "./templates/block.hbs"
}
},
"defaultColor": "light-gray",
"onDemandOnly": true,
"request": {
"cert": "",
"key": "",
"passphrase": "",
"ca": "",
"proxy": ""
},
"options": [
{
"key": "topPorts",
"name": "Number of the Most Popular Ports to Scan",
"description": "This setting controls how many ports will be scanned based on NMAP's built in port popularity",
"default": 64,
"type": "number",
"userCanEdit": false,
"adminOnly": true
},
{
"key": "privateIpOnly",
"name": "Private IPs Only",
"description": "If checked, the integration will only be available for private (RFC-1918) IP addresses.",
"default": false,
"type": "boolean",
"userCanEdit": false,
"adminOnly": true
}
]
}
Binary file added images/overlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b94a4f4

Please sign in to comment.