• Stars
    star
    105
  • Rank 326,287 (Top 7 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Database migration (evolution) tool for Apache Cassandra

Cassandra Migration

A simple and lightweight migration tool for Apache Cassandra database that's based on Axel Fontaine's Flyway project. Cassandra Migration works just like Flyway. Plain CQL and Java based migrations are supported. The Java migration interface provides DataStax's Java Driver session.

Why not create an extension to an existing popular database migration project (i.e. Flyway)?

Popular database migration tools, such as Flyway and Liquibase are tailored for relational databases with JDBC. This project exists because...

  • Cassandra is not a relational database
  • Cassandra does not have transactions
  • Cassandra currently does not have production-ready JDBC implementation
  • It does not make sense to attempt implementing parity with relational database functions like global sequence IDs for Cassandra
  • Cassandra's keyspace should be managed outside the migration tool for sysadmins to configure replication factor, etc
  • CQL != SQL
  • The tool should be tailored to Cassandra, especially from the perspective of its distributed architecture
  • I already use Flyway and I do not want to maintain my own version of Flyway with Cassandra hacks

Requirements

  • Java (Tested with JDK 7+)
  • Apache Cassandra (Tested with 2.1.5+)
  • Pre-populated keyspace
  • Cassandra Migration library
<dependency>
    <groupId>com.contrastsecurity</groupId>
    <artifactId>cassandra-migration</artifactId>
    <version>0.6</version>
</dependency>

Migration version table

cassandra@cqlsh:cassandra_migration_test> select * from cassandra_migration_version;
 type        | version | checksum    | description    | execution_time | installed_by | installed_on             | installed_rank | script                                 | success | version_rank
-------------+---------+-------------+----------------+----------------+--------------+--------------------------+----------------+----------------------------------------+---------+--------------
         CQL |   1.0.0 |   985950023 |          First |             88 |    cassandra | 2015-09-12 15:10:22-0400 |              1 |                      V1_0_0__First.cql |    True |            1
         CQL |   1.1.2 |  2095193138 |  Late arrival2 |              3 |    cassandra | 2015-09-12 15:10:23-0400 |              5 |              V1_1_2__Late_arrival2.cql |    True |            2
         CQL |   1.1.3 | -1648933960 |  Late arrival3 |             15 |    cassandra | 2015-09-12 15:10:23-0400 |              6 |              V1_1_3__Late_arrival3.cql |    True |            3
         CQL |   2.0.0 |  1899485431 |         Second |            154 |    cassandra | 2015-09-12 15:10:22-0400 |              2 |                     V2_0_0__Second.cql |    True |            4
 JAVA_DRIVER |     3.0 |        null |          Third |              3 |    cassandra | 2015-09-12 15:10:22-0400 |              3 |            migration.integ.V3_0__Third |    True |            5
 JAVA_DRIVER |   3.0.1 |        null | Three zero one |              2 |    cassandra | 2015-09-12 15:10:22-0400 |              4 | migration.integ.V3_0_1__Three_zero_one |    True |            6

Supported Migration Script Types

.cql files

Example:

CREATE TABLE test1 (
  space text,
  key text,
  value text,
  PRIMARY KEY (space, key)
) with CLUSTERING ORDER BY (key ASC);

INSERT INTO test1 (space, key, value) VALUES ('foo', 'blah', 'meh');

UPDATE test1 SET value = 'profit!' WHERE space = 'foo' AND key = 'blah';

Java classes

Example:

public class V3_0__Third implements JavaMigration {

    @Override
    public void migrate(Session session) throws Exception {
        Insert insert = QueryBuilder.insertInto("test1");
        insert.value("space", "web");
        insert.value("key", "google");
        insert.value("value", "google.com");

        session.execute(insert);
    }
}

Interface

Java API

Example:

String[] scriptsLocations = {"migration/cassandra"};

Keyspace keyspace = new Keyspace();
keyspace.setName(CASSANDRA__KEYSPACE);
keyspace.getCluster().setContactpoints(CASSANDRA_CONTACT_POINT);
keyspace.getCluster().setPort(CASSANDRA_PORT);
keyspace.getCluster().setUsername(CASSANDRA_USERNAME);
keyspace.getCluster().setPassword(CASSANDRA_PASSWORD);

CassandraMigration cm = new CassandraMigration();
cm.getConfigs().setScriptsLocations(scriptsLocations);
cm.setKeyspace(keyspace);
cm.migrate();

Command line

java -jar \
-Dcassandra.migration.scripts.locations=file:target/test-classes/migration/integ \
-Dcassandra.migration.cluster.contactpoints=localhost \
-Dcassandra.migration.cluster.port=9147 \
-Dcassandra.migration.cluster.username=cassandra \
-Dcassandra.migration.cluster.password=cassandra \
-Dcassandra.migration.keyspace.name=cassandra_migration_test \
target/*-jar-with-dependencies.jar migrate

Logging level can be set by passing the following arguments:

  • INFO: This is the default
  • DEBUG: '-X'
  • WARNING: '-q'

VM Options

Options can be set either programmatically with API or via VM options.

Migration

  • cassandra.migration.scripts.locations: Locations of the migration scripts in CSV format. Scripts are scanned in the specified folder recursively. (default=db/migration)
  • cassandra.migration.scripts.encoding: The encoding of CQL scripts (default=UTF-8)
  • cassandra.migration.scripts.allowoutoforder: Allow out of order migration (default=false)
  • cassandra.migration.version.target: The target version. Migrations with a higher version number will be ignored. (default=latest)

Cluster

  • cassandra.migration.cluster.contactpoints: Comma separated values of node IP addresses (default=localhost)
  • cassandra.migration.cluster.port: CQL native transport port (default=9042)
  • cassandra.migration.cluster.username: Username for password authenticator (optional)
  • cassandra.migration.cluster.password: Password for password authenticator (optional)

Keyspace

  • cassandra.migration.keyspace.name: Name of Cassandra keyspace (required)

Cluster Coordination

  • Schema version tracking statements use ConsistencyLevel.ALL
  • Users should manage their own consistency level in the migration scripts

Limitations

  • Baselining not supported yet
  • The tool does not roll back the database upon migration failure. You're expected to manually restore backup.

More Repositories

1

contrast-rO0

A tiny Java agent that blocks attacks against unsafe deserialization
Java
79
star
2

DjanGoat

Python and Django implementation of the OWASP RailsGoat project
Python
68
star
3

safelog4j

Safelog4j is an instrumentation-based security tool to help teams discover, verify, and solve log4shell vulnerabilities without scanning or upgrading
Java
41
star
4

joogle

A static analysis API for finding deserialization attack gadgets
Java
36
star
5

go-test-bench

Intentionally vulnerable Go web app.
Go
35
star
6

jinfinity

An API for consuming all the memory of Java apps using deserialization
Java
28
star
7

java-sarif

POJOs generated from the Static Analysis Results Interchange Format (SARIF) JSON schema.
Java
19
star
8

contrastscan-action

Contrast Scan GitHub action
Shell
19
star
9

sheepdog

Java
16
star
10

agent-operator

A K8s operator to inject agents into existing K8s workloads.
C#
15
star
11

vulnpy

Purposely-vulnerable Python functions
Python
15
star
12

docs

Groovy
15
star
13

NodeTestBench

Intentionally Vulnerable Node Applications
JavaScript
15
star
14

vulnerable-spring-boot-application

Java
13
star
15

Burptrast

Burp Plugin for Contrast Security
Java
10
star
16

NodeTestBenches

A collection of intentionally vulnerable test bench applications for testing the Contrast Security Node Agent.
JavaScript
9
star
17

contrast-sdk-java

Java SDK for Contrast Security
Java
8
star
18

join-the-team

Information about working with the Contrast Engineering Team.
8
star
19

ticketbook

This is a purposely insecure web application.
Java
7
star
20

contrast-sca-action

Contrast SCA GitHub Action
7
star
21

demo-netflicks

C#
6
star
22

contrast-sdk-dotnet

.Net API for the Contrast REST API
C#
6
star
23

contrast-maven-plugin

Contrast Maven Plugin
Java
5
star
24

meow

HTML
5
star
25

java-microservice-sample-apps

A small microservice that demonstrating how Contrast works with microservices
Java
4
star
26

contrast-sdk-python

Python
4
star
27

serialbox

Java
4
star
28

integration-eks-github-action

A github action that builds, deploys, and instruments a Contrast Security Agent with an application via Amazon Elastic Kubernetes Service.
Shell
4
star
29

demo-terracotta-bank

Java
3
star
30

webgoat

JavaScript
3
star
31

ops-hire-project

Contrast Operations Hire Project
3
star
32

integration-azure-spring-cloud-github-action

A github action that deploys and instruments a Contrast Security Agent with an application via Azure Spring Cloud.
Shell
3
star
33

mysql-forensics-tool

Tool for generating MySQL forensics specifically for TeamServer.
PLpgSQL
3
star
34

integration-verify-github-action

GitHub Action to verify an application by determining whether the application violates a job outcome policy or threshold of open vulnerabilities
Python
3
star
35

integration-aks-github-action

A github action that builds, deploys, and instruments a Contrast Security Agent with an application via Azure Kubernetes Service.
Shell
3
star
36

contrast-dotnet-examples

Example code examples and scripts to complement documentation for Contrast .NET Agents
PowerShell
3
star
37

workshop

Contrast Security Workshop
Ruby
2
star
38

dotnet-dvnr

Standalone utility for collecting Windows IIS server information
C#
2
star
39

sdet-hire-project

A set of directions for SDET candidates to complete
2
star
40

contrast-chrome-extension

JavaScript
2
star
41

demo-petclinic

TypeScript
2
star
42

contrast-security-orb

Contrast Security Orb for CircleCI
2
star
43

KoaTestBench

Intentionally Vulnerable Koa Application
JavaScript
2
star
44

integrations-scw

Script to populate a Contrast environment with links to Secure Code Warrior videos and training exercises.
Python
2
star
45

contrast-security-oss.github.io

HTML
2
star
46

log4shell_serverless

Exploit of the log4shell vulnerability in an AWS Lambda function
Java
2
star
47

demo-webgoat7

TypeScript
2
star
48

Google-Apps-Script

Google Apps Scripts for connecting TeamServer with Google Apps such as Sheets
2
star
49

react-test-bench

Intentionally vulnerable React web application for exercising vulnerability detection
JavaScript
2
star
50

AdminTool

Java
2
star
51

contrast-teamserver-api-docs

2
star
52

demo-webgoat.net

C#
2
star
53

ansible-packer-docker

Build an ansible-packer Docker container
Dockerfile
2
star
54

home-automation

Java
2
star
55

contrast-integrations-cli

A CLI tool for adding Contrast Integrations via rule customizations.
Python
2
star
56

ContrastSplunkApp

Contrast Security App for Splunk
Python
2
star
57

contrastsecurity-node-docker-onboarding-guide-sample-project

This repo is a companion to the Contrast agent deployment in Docker - Node.js guide.
Shell
1
star
58

contrast-intellij-plugin

Java
1
star
59

maven-yarn-docker

Dockerfile which builds an image containing maven and yarn build tools
Dockerfile
1
star
60

contrast-scan-owasp-scorer

Java
1
star
61

vizt

A command line tool for visualizing Contrast trace XML exports.
Python
1
star
62

chef-contrast-java-agent

A Chef cookbook to install the contrast security java agent.
Ruby
1
star
63

vulneruby_engine

Ruby
1
star
64

proxy-agent-docker

Docker images for building, deploying, and testing Contrast proxy (WAF) agent
Dockerfile
1
star
65

contrast-sdk-javascript

JavaScript
1
star
66

attack-load-generator

Python
1
star
67

SailsTestBench

Intentionally Vulnerable Sails Applications
JavaScript
1
star
68

maven-cross-openjdk-docker

Dockerfile
1
star
69

contrast-java-examples

Java
1
star
70

demo-nodegoat

HTML
1
star
71

demo-k8s-operator

HCL
1
star
72

contrast-sdk-ruby

Ruby
1
star
73

node-aws-docker

Docker image for building node projects and deploying to AWS Lambda
1
star
74

agent-teamserver-tests

Shell
1
star
75

contrast-gradle-plugin

Groovy
1
star
76

oapi-build-docker

Tools for building Open API specification projects in CI
Dockerfile
1
star
77

eop-examples

Setting up EOP TeamServer on Various Platforms
Shell
1
star
78

vulneruby

Ruby
1
star
79

spring-petclinic

A sample Spring-based application
Java
1
star
80

nginx-contrast-connector

readonly mirror of contrast nginx-contrast-connector repo.
C
1
star
81

azure-aks-example

C#
1
star
82

infrastructure-hire-project

HCL
1
star
83

ContrastDataDogDashboard

1
star