Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial release of Capa Explorer Web #2224

Merged
merged 79 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
6bec5d4
webui: initial release
s-ff Jul 22, 2024
c3aa306
add Github Pages deployement workflow
s-ff Jul 22, 2024
2862cb3
remove Github Pages workflow from webui branch
s-ff Jul 22, 2024
09d8624
add package-lock.json cache
Jul 22, 2024
5c60efa
add Github Pages deployment workflow
s-ff Jul 22, 2024
3c27497
Remove demo rdoc json files (static and dynamic)
s-ff Jul 22, 2024
626ea51
use existings tests/data/rd rdocs for Preview
s-ff Jul 23, 2024
9db01e3
add href links to MBC, and refactor into helpers functions
s-ff Jul 23, 2024
277e9d1
remove Toolset dropdown menu
s-ff Jul 23, 2024
106c317
link sha256 to VT external link
s-ff Jul 23, 2024
6da0e5d
highlight links, use monospace for feature values
s-ff Jul 24, 2024
12f1851
deploy-webui.yml: include submodule capa-rules checkout
s-ff Jul 24, 2024
3f33b82
changelog: add webui
s-ff Jul 24, 2024
0028da5
implement text truncation for process names
s-ff Jul 24, 2024
4aad53c
feature: implement parent-child process tree
s-ff Jul 24, 2024
d25c86c
reformat function capabilities into a rowspan table instead of tree t…
s-ff Jul 26, 2024
e3f695b
bump upload size limit to 100MB
s-ff Jul 26, 2024
029259b
make rule names and matches click event expand the node
s-ff Jul 28, 2024
d81b123
feature: add right click links context menu
s-ff Jul 28, 2024
38cf1f1
feature: show regex captures
s-ff Jul 29, 2024
13261d0
include basic block matches in capabilities by function table
s-ff Jul 29, 2024
e70e1b0
feature: add call information to api feature in dynamic mode (-vv)
s-ff Jul 30, 2024
b6f0ee5
wip: only include process name in api call details
s-ff Jul 30, 2024
f60e3fc
lints
s-ff Jul 30, 2024
62701a2
use Hash-Based routing (#)
s-ff Jul 30, 2024
f6bc425
if node already expanded, toggle it off
s-ff Jul 30, 2024
0ea6f1e
fix: do not toggle/on feature and statements
s-ff Jul 30, 2024
b7b8792
Force reload the page on Import Analysis
s-ff Jul 31, 2024
4fe7f78
edit code comments
s-ff Jul 31, 2024
b229048
feature: show namespace chart
s-ff Aug 1, 2024
b74738a
feature: show namespace chart
s-ff Aug 1, 2024
9107819
fix: force reload page on import analysis
s-ff Aug 1, 2024
8e9eadf
feature: support gzipped rdoc
s-ff Aug 1, 2024
33be4d1
dynamic: only show first 20 matches per rule
s-ff Aug 1, 2024
4137923
dynamic: revert to showing 1 match per rule
s-ff Aug 1, 2024
07b4e1f
implement unit test
s-ff Aug 1, 2024
b0ffc86
fix lint error
s-ff Aug 1, 2024
67d3916
add lint and test steps to deploy workflow
s-ff Aug 1, 2024
a6884db
fix: add lint and test steps to deploy workflow
s-ff Aug 2, 2024
eb69b38
move url creation function to util/urlHelpers.js
s-ff Aug 5, 2024
7cb93c8
update .prettierrc.json, and reformat code
s-ff Aug 5, 2024
fcf200f
fix metadata panel on small screens
s-ff Aug 5, 2024
d609203
add 404 page
s-ff Aug 5, 2024
bb60099
rename window title to 'Capa Explorer'
s-ff Aug 5, 2024
6b19e7b
add README.md for Capa Explorer WebUI
s-ff Aug 5, 2024
7e64306
move webui to web/explorer
s-ff Aug 5, 2024
bb1ef6c
move package-lock.json to web/explorer
Aug 5, 2024
e9e5d2b
delete webui
s-ff Aug 5, 2024
ebb778a
delete webui/package-lock.json
Aug 5, 2024
f856ea7
modify deploy-webui.yml workflow to user web/explorer
s-ff Aug 5, 2024
283aa27
add DEVELOPMENT.md
s-ff Aug 5, 2024
fcdaabf
update development links
s-ff Aug 5, 2024
a15eb83
format code
s-ff Aug 5, 2024
ac08133
Merge branch 'master' into webui
s-ff Aug 5, 2024
b675c9a
change target branch to master in deploy-webui.yml
s-ff Aug 5, 2024
765c7cb
add on pull_request trigger to deploy-webui.yml
s-ff Aug 5, 2024
ebfba54
fix Metadata panel on smaller screens
s-ff Aug 6, 2024
db423d9
add comments to rule column components
s-ff Aug 6, 2024
dfc19d8
Update docuemntation
s-ff Aug 8, 2024
843fd34
changelog: update entry
s-ff Aug 8, 2024
97bd499
add path resolving shortcuts "@"
s-ff Aug 8, 2024
6b8983c
simplify function capabilities
s-ff Aug 8, 2024
20d7bf1
gitignore: update gitignore
s-ff Aug 8, 2024
01e6619
update Import Analysis url
s-ff Aug 8, 2024
7cb31cf
refactor: add new URL creation helper functions for VT and capa-rules
s-ff Aug 8, 2024
1f6ce48
refactor RuleMatchesTable
s-ff Aug 8, 2024
287e428
set web-app version to 1.0.0
s-ff Aug 8, 2024
368f635
minor fixes: NamespaceChart and ProcessCapabilities
s-ff Aug 8, 2024
bb8991a
fix formatting
s-ff Aug 8, 2024
e8ea461
fix formatting
s-ff Aug 8, 2024
e8054c2
add deploy and tests workflows
s-ff Aug 8, 2024
850ae5a
tests: update unit tests after refactoring parseFunctionCapabilities
s-ff Aug 8, 2024
9d137a2
replace path traversal with @ path shortcut
s-ff Aug 8, 2024
05575e1
encore rdoc query paramter URL
s-ff Aug 8, 2024
1af97f6
update web workflow Format steps to use npm run format:check
s-ff Aug 8, 2024
ba9ab7c
Update web/explorer/DEVELOPMENT.md
williballenthin Aug 8, 2024
6b8e2b3
Update web/explorer/README.md
williballenthin Aug 8, 2024
44cbe66
Update web/explorer/README.md
williballenthin Aug 8, 2024
312dd0d
Merge branch 'master' into webui
williballenthin Aug 8, 2024
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
66 changes: 66 additions & 0 deletions .github/workflows/deploy-webui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: deploy Capa Explorer Web to Github Pages

on:
# Runs on pushes targeting the webui branch
push:
branches: [ master ]
paths:
- 'web/explorer/**'

# Allows to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: true

jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 1
show-progress: true
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: './web/explorer/package-lock.json'
- name: Install dependencies
run: npm ci
working-directory: ./web/explorer
- name: Lint
run: npm run lint
working-directory: ./web/explorer
- name: Format
run: npm run format:check
working-directory: ./web/explorer
- name: Run unit tests
run: npm run test
working-directory: ./web/explorer
- name: Build
run: npm run build
working-directory: ./web/explorer
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './web/explorer/dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
s-ff marked this conversation as resolved.
Show resolved Hide resolved
42 changes: 42 additions & 0 deletions .github/workflows/web-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Capa Explorer Web tests

on:
pull_request:
branches: [ master ]
paths:
- 'web/explorer/**'
Comment on lines +6 to +7
Copy link
Collaborator Author

Choose a reason for hiding this comment

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


jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 1
show-progress: true

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
cache-dependency-path: './web/explorer/package-lock.json'

- name: Install dependencies
run: npm ci
working-directory: ./web/explorer

- name: Lint
run: npm run lint
working-directory: ./web/explorer

- name: Format
run: npm run format:check
working-directory: ./web/explorer

- name: Run unit tests
run: npm run test
working-directory: ./web/explorer
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
## master (unreleased)

### New Features

- webui: explore capa analysis results in a web-based UI online and offline #2224 @s-ff
- support analyzing DRAKVUF traces #2143 @yelhamer


### Breaking Changes

### New Rules (2)
Expand Down
13 changes: 13 additions & 0 deletions web/explorer/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-env node */
require("@rushstack/eslint-patch/modern-module-resolution");

module.exports = {
root: true,
extends: ["plugin:vue/vue3-essential", "eslint:recommended", "@vue/eslint-config-prettier/skip-formatting"],
parserOptions: {
ecmaVersion: "latest"
},
rules: {
"vue/multi-word-component-names": "off"
}
};
30 changes: 30 additions & 0 deletions web/explorer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

# Dependencies, build results, and other generated files
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.vscode
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# TypeScript incremental build info
*.tsbuildinfo
8 changes: 8 additions & 0 deletions web/explorer/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": true,
"tabWidth": 4,
"singleQuote": false,
"printWidth": 120,
"trailingComma": "none"
}
123 changes: 123 additions & 0 deletions web/explorer/DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Development Guide for Capa Explorer Web

This guide will help you set up the Capa Explorer Web project for local development.

## Prerequisites

Before you begin, ensure you have the following installed:

- Node.js (v20.x or later recommended)
- npm (v10.x or later)
- Git

## Setting Up the Development Environment

1. Clone the repository:

```
git clone https://github.com/mandiat/capa.git
cd capa/web/explorer
```

2. Install dependencies:

```
npm install
```

3. Start the development server:

```
npm run dev
```

This will start the Vite development server. The application should now be running at `http://localhost:<port>`

## Project Structure

```
web/exporer/
├── src/
│ ├── assets/
│ ├── components/
│ ├── composables/
│ ├── router/
│ ├── utils/
│ ├── views/
│ ├── App.vue
│ └── main.js
├── public/
├── tests/
├── index.html
├── package.json
├── vite.config.js
├── DEVELOPMENT.md
└── README.md
```

- `src/`: Contains the source code of the application
- `src/components/`: Reusable Vue components
- `src/composables/`: Vue composition functions
- `src/router/`: Vue Router configuration
- `src/utils/`: Utility functions
- `src/views/`: Top-level views/pages
- `src/tests/`: Test files
- `public/`: Static assets that will be served as-is

## Building for Production

To build the application for production:

```
npm run build
```

This will generate production-ready files in the `dist/` directory.

Or, you can build a standalone bundle application that can be used offline:

```
npm run build:bundle
```

This will generate an offline HTML bundle file in the `dist/` directory.

## Testing

Run the test suite with:

```
npm run test
```

We use Vitest as our testing framework. Please ensure all tests pass before submitting a pull request.

## Linting and Formatting

We use ESLint for linting and Prettier for code formatting. Run the linter with:

```
npm run lint
npm run format
```

## Working with PrimeVue Components

Capa Explorer Web uses the PrimeVue UI component library. When adding new features or modifying existing ones, refer to the [PrimeVue documentation](https://primevue.org/vite) for available components and their usage.

## Best Practices

1. Follow the [Vue.js Style Guide](https://vuejs.org/style-guide/) for consistent code style.
2. Document new functions, components, and complex logic.
3. Write tests for new features and bug fixes.
4. Keep components small and focused on a single responsibility.
5. Use composables for reusable logic across components.

## Additional Resources

- [Vue.js Documentation](https://vuejs.org/guide/introduction.html)
- [Vite Documentation](https://vitejs.dev/guide/)
- [Vitest Documentation](https://vitest.dev/guide/)
- [PrimeVue Documentation](https://www.primevue.org/)

If you encounter any issues or have questions about the development process, please open an issue on the GitHub repository.
41 changes: 41 additions & 0 deletions web/explorer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Capa Explorer Web

Capa Explorer Web is a browser-based user interface for exploring program capabilities identified by capa. It provides an intuitive and interactive way to analyze and visualize the results of capa analysis.

## Features

- **Import capa Results**: Easily upload or import capa JSON result files.
- **Interactive Tree View**: Explore and filter rule matches in a hierarchical structure.
- **Function Capabilities**: Group and filter capabilities by function for static analysis.
- **Process Capabilities**: Group capabilities by process for dynamic analysis.

## Getting Started

1. **Access the Application**: Open Capa Explorer Web in your web browser.
You can start using Capa Explorer Web by accessing [https://mandiant.github.io/capa](https://mandiant.github.io/capa/) or running it locally by dowloading the offline release in the [releases](https://github.com/mandiant/capa/releases) section and loading it in your browser.

2. **Import capa Results**:

- Click on "Upload from local" to select a capa analysis document file from your computer (with a version higher than 7.0.0).
- Or, paste a URL to a capa JSON file and click the arrow button to load it.
- Alternatively, use the "Preview Static" or "Preview Dynamic" for sample data.

3. **Explore the Results**:

- Use the tree view to navigate through the identified capabilities.
- Toggle between different views using the checkboxes in the settings panel:
- "Show capabilities by function/process" for grouped analysis.
- "Show library rule matches" to include or exclude library rules.

4. **Interact with the Data**:
- Expand/collapse nodes in the table to see more details.
- Use the search and filter options to find specific features, functions or capabilities (rules).
- Right click on rule names to view their source code or additional information.

## Feedback and Contributions

We welcome your feedback and contributions to improve the web-based Capa Explorer. Please report any issues or suggest enhancements through the `capa` GitHub repository.

---

For developers interested in building or contributing to Capa Explorer WebUI, please refer to our [Development Guide](DEVELOPMENT.md).
13 changes: 13 additions & 0 deletions web/explorer/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/public/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Capa Explorer</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
8 changes: 8 additions & 0 deletions web/explorer/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
}
},
"exclude": ["node_modules", "dist"]
}
Loading
Loading