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

Change urldownloader to use service template #94

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"template": "[email protected]:CybercentreCanada/assemblyline-service-template.git",
"commit": "349a8390e48c1607f6dc245add2627df07c7bc9b",
"checkout": null,
"context": {
"cookiecutter": {
"service_name": "urldownloader",
"__svc_name": "urldownloader",
"__repository": "assemblyline-service-urldownloader",
"__pkg_name": "urldownloader",
"class_name": "URLDownloader",
"short_description": "This Assemblyline service crawls URLs and records communications with the URL.",
"short_description_fr": "Ce service Assemblyline explore les URL et enregistre les communications avec l'URL.",
"stage": "CORE",
"category": "Internet Connected",
"org_name_full": "CybercentreCanada",
"org_name_short": "cccs",
"license": "mit",
"_template": "[email protected]:CybercentreCanada/assemblyline-service-template.git"
}
},
"directory": null
}
5 changes: 2 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ coverage.xml
*.cover
*.log

**/*.jar
**/coqui-stt.zip
**/chromedriver
-**/*.jar
-**/chromedriver
149 changes: 142 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Created by https://www.toptal.com/developers/gitignore/api/python,vim,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=python,vim,visualstudiocode

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand All @@ -6,11 +10,6 @@ __pycache__/
# C extensions
*.so

# IDE files
.pydevproject
.python-version
.idea

# Distribution / packaging
.Python
build/
Expand Down Expand Up @@ -60,6 +59,22 @@ cover/
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/
Expand All @@ -71,6 +86,43 @@ target/
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
Expand All @@ -80,10 +132,93 @@ ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

*.pyc
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

### Python Patch ###
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
poetry.toml

# ruff
.ruff_cache/

# LSP config files
pyrightconfig.json

### Vim ###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/python,vim,visualstudiocode

# IDE files
.pydevproject
.python-version

# Kangooroo specific files
chromedriver
KangoorooStandalone.jar
coqui-stt.zip
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"version": "0.2.0",
"configurations": [
{
"name": "RunServiceOnce",
"name": "RunServiceOnce URLDownloader",
"type": "python",
"request": "launch",
"module": "assemblyline_v4_service.dev.run_service_once",
"cwd": "${workspaceFolder}",
"args": [
"-d",
"urldownloader.URLDownloader",
"/path/to/sample"
"urldownloader.urldownloader.URLDownloader",
"${file}"
],
"justMyCode": false,
},
Expand All @@ -25,7 +25,7 @@
"env": {
"SERVICE_MANIFEST_PATH": "service_manifest.yml",
"PRIVILEGED": "true",
"SERVICE_PATH": "urldownloader.URLDownloader",
"SERVICE_PATH": "urldownloader.urldownloader.URLDownloader",
"TASKING_DIR": "/tmp/URLDownloader"
},
"console": "internalConsole",
Expand Down
34 changes: 34 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Assemblyline contributing guide

This guide covers the basics of how to contribute to the Assemblyline project.

Python code should follow the PEP8 guidelines defined here:
[PEP8 Guidelines](https://www.python.org/dev/peps/pep-0008/).

## Tell us want you want to build/fix

Before you start coding anything you should connect with the Assemblyline community via the
[Assemblyline Discord server](https://discord.gg/GUAy9wErNu) and/or the
[central Assemblyline GitHub project](https://github.com/CybercentreCanada/assemblyline/issues) to make sure no one
else is working on the same thing and that whatever you are going to build still fits with the vision of the system.

## Git workflow

- Clone the repo to your own account
- Checkout and pull the latest commits from the master branch
- Make a branch
- Work on your modifications and make sure your changes work as expected
- When you're satisfied with your changes, create a pull requests to the Assemblyline repo

#### Transfer your service repo

If you've worked on a new service that you want to be included in the default service selection you'll have to transfer
the associated repo into our control.

#### You are not allow to merge:

Even if you try to merge in your pull request, you will be denied. Only a few people in our team are allowed to merge
code into our repositories.

We check for new pull requests every day and will merge them in once they have been approved by someone in our team.

29 changes: 19 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
ARG branch=latest
FROM cccs/assemblyline-v4-service-base:$branch

ENV SERVICE_PATH=urldownloader.URLDownloader
# Python path to the service class from your service directory
ENV SERVICE_PATH=urldownloader.urldownloader.URLDownloader

ENV KANGOOROO_VERSION=v2.0.1.stable12
USER root

RUN apt update -y && \
apt install -y wget default-jre unzip ffmpeg && \
# Install apt dependencies
USER root
COPY pkglist.txt /tmp/setup/
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
$(grep -vE "^\s*(#|$)" /tmp/setup/pkglist.txt | tr "\n" " ") && \
rm -rf /tmp/setup/pkglist.txt && \
# Install chromedriver and kangooroo
# Find out what is the latest version of the chrome-for-testing/chromedriver available
VERS=$(wget -q -O - https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_STABLE) && \
# Download + Install google-chrome with the version matching the latest chromedriver
wget -O ./google-chrome-stable_amd64.deb https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_$VERS-1_amd64.deb && \
apt install -y ./google-chrome-stable_amd64.deb && \
rm -rf /var/lib/apt/lists/* && \
Expand All @@ -24,17 +31,19 @@ RUN apt update -y && \
unzip -j ./KangoorooStandalone.zip KangoorooStandalone/bin/* -d /opt/al_service/kangooroo/bin && \
rm -f ./KangoorooStandalone.zip


# Switch to assemblyline user
# Install python dependencies
USER assemblyline
COPY requirements.txt requirements.txt
RUN pip install \
--no-cache-dir \
--user \
--requirement requirements.txt && \
rm -rf ~/.cache/pip

# Copy service code
WORKDIR /opt/al_service
COPY . .

# Install python dependencies
RUN pip install --no-cache-dir --user --requirement requirements.txt && rm -rf ~/.cache/pip

# Patch version in manifest
ARG version=4.0.0.dev1
USER root
Expand Down
22 changes: 16 additions & 6 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
MIT License

Copyright (c) 2020 Crown Copyright, Government of Canada (Canadian Centre for Cyber Security / Communications Security Establishment)
Copyright (c) 2025 CybercentreCanada

Copyright title to all 3rd party software distributed with Assemblyline (AL) is held by the respective copyright holders as noted in those files. Users are asked to read the 3rd Party Licenses referenced with those assets.
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:

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 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.
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.
26 changes: 26 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
ifndef VERSION
$(error VERSION is undefined)
endif

TAG?=latest
ORG?=cccs

ifneq ($(ORG)x, x)
ORG:=$(ORG)/
endif
ifneq ($(REGISTRY)x, x)
ORG:=$(REGISTRY)/
endif

.PHONY: default
default: build

.PHONY: build
build:
docker build \
--pull \
--build-arg version=$(VERSION) \
--build-arg branch=stable \
-t $(REGISTRY)$(ORG)assemblyline-service-urldownloader:$(TAG)\
-f ./Dockerfile \
.
Loading