From e8d8ee5d79f45c5449c98fcffe7cc3987a323005 Mon Sep 17 00:00:00 2001 From: alon-e Date: Mon, 12 Jun 2017 21:06:21 +0300 Subject: [PATCH 1/3] added input validation to depth & minWeightMagnitude enforce non empty array lists getTrytes limit added addNeighbor print --- Dockerfile | 2 +- changelog.txt | 3 ++ dependency-reduced-pom.xml | 2 +- pom.xml | 2 +- src/main/java/com/iota/iri/IRI.java | 2 +- .../java/com/iota/iri/conf/Configuration.java | 2 ++ src/main/java/com/iota/iri/service/API.java | 33 ++++++++++++++----- 7 files changed, 33 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 320b9f1f65..6cdff82765 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,3 @@ FROM java:8 -CMD ["/usr/bin/java", "-jar", "iri-1.2.0.jar"] +CMD ["/usr/bin/java", "-jar", "iri-1.2.1.jar"] diff --git a/changelog.txt b/changelog.txt index 75d921e07e..d7dfdc9f7e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +1.2.1 + - cleaner API messaging + 1.2.0 - Mainnet release with MWM 15 - Snapshot diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index cd7caa99d7..c075d7b4c6 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -4,7 +4,7 @@ com.iota iri IRI - 1.2.0 + 1.2.1 IOTA Reference Implementation scm:git:git://github.com/iotaledger/iri.git diff --git a/pom.xml b/pom.xml index 10978b60e4..af9c17ad09 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.iota iri - 1.2.0 + 1.2.1 IRI IOTA Reference Implementation diff --git a/src/main/java/com/iota/iri/IRI.java b/src/main/java/com/iota/iri/IRI.java index afb7c9eaac..64cbdc20be 100644 --- a/src/main/java/com/iota/iri/IRI.java +++ b/src/main/java/com/iota/iri/IRI.java @@ -40,7 +40,7 @@ public class IRI { public static final String MAINNET_NAME = "IRI"; public static final String TESTNET_NAME = "IRI Testnet"; - public static final String VERSION = "1.2.0"; + public static final String VERSION = "1.2.1"; public static Iota iota; public static API api; public static IXI ixi; diff --git a/src/main/java/com/iota/iri/conf/Configuration.java b/src/main/java/com/iota/iri/conf/Configuration.java index f49841bcf2..1a0a615831 100644 --- a/src/main/java/com/iota/iri/conf/Configuration.java +++ b/src/main/java/com/iota/iri/conf/Configuration.java @@ -50,6 +50,7 @@ public enum DefaultConfSettings { RESCAN_DB, MAX_RANDOM_WALKS, MAX_FIND_TRANSACTIONS, + MAX_GET_TRYTES, MAX_DEPTH, MAINNET_MWM, TESTNET_MWM, @@ -89,6 +90,7 @@ public enum DefaultConfSettings { conf.put(DefaultConfSettings.MAX_DEPTH.name(), "15"); conf.put(DefaultConfSettings.MAX_FIND_TRANSACTIONS.name(), "100000"); + conf.put(DefaultConfSettings.MAX_GET_TRYTES.name(), "10000"); } diff --git a/src/main/java/com/iota/iri/service/API.java b/src/main/java/com/iota/iri/service/API.java index 19489476bc..9ff648f6a3 100644 --- a/src/main/java/com/iota/iri/service/API.java +++ b/src/main/java/com/iota/iri/service/API.java @@ -19,7 +19,6 @@ import java.util.Map; import java.util.Queue; import java.util.Set; -import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -97,6 +96,7 @@ public class API { private final int maxRandomWalks; private final int maxFindTxs; + private final int maxGetTrytes; private final static char ZERO_LENGTH_ALLOWED = 'Y'; private final static char ZERO_LENGTH_NOT_ALLOWED = 'N'; @@ -107,6 +107,7 @@ public API(Iota instance, IXI ixi) { this.ixi = ixi; maxRandomWalks = instance.configuration.integer(DefaultConfSettings.MAX_RANDOM_WALKS); maxFindTxs = instance.configuration.integer(DefaultConfSettings.MAX_FIND_TRANSACTIONS); + maxGetTrytes = instance.configuration.integer(DefaultConfSettings.MAX_GET_TRYTES); } @@ -201,7 +202,12 @@ private AbstractResponse process(final String requestString, InetSocketAddress s } final Hash trunkTransaction = new Hash((String) request.get("trunkTransaction")); final Hash branchTransaction = new Hash((String) request.get("branchTransaction")); - final int minWeightMagnitude = ((Double) request.get("minWeightMagnitude")).intValue(); + final int minWeightMagnitude; + try { + minWeightMagnitude = ((Double) request.get("minWeightMagnitude")).intValue(); + } catch (ClassCastException e) { + return ErrorResponse.create("Invalid minWeightMagnitude input"); + } final List trytes = (List) request.get("trytes"); for (final String tryt : trytes) { if (!validTrytes(tryt, TRYTES_SIZE, ZERO_LENGTH_NOT_ALLOWED)) { @@ -287,7 +293,12 @@ private AbstractResponse process(final String requestString, InetSocketAddress s return getTipsStatement(); } case "getTransactionsToApprove": { - final int depth = ((Double) request.get("depth")).intValue(); + final int depth; + try { + depth = ((Double) request.get("depth")).intValue(); + } catch (ClassCastException e) { + return ErrorResponse.create("Invalid depth input"); + } final Object referenceObj = request.get("reference"); final String reference = referenceObj == null? null: (String) referenceObj; if (invalidSubtangleStatus()) { @@ -311,7 +322,7 @@ private AbstractResponse process(final String requestString, InetSocketAddress s return ErrorResponse.create("Wrong arguments"); } for (final String hash : hashes) { - if (!validTrytes(hash, HASH_SIZE, ZERO_LENGTH_ALLOWED)) { + if (!validTrytes(hash, HASH_SIZE, ZERO_LENGTH_NOT_ALLOWED)) { return ErrorResponse.create("Invalid hash input"); } } @@ -389,7 +400,7 @@ private AbstractResponse removeNeighborsStatement(List uris) throws URIS return RemoveNeighborsResponse.create(numberOfRemovedNeighbors.get()); } - private AbstractResponse getTrytesStatement(List hashes) throws Exception { + private synchronized AbstractResponse getTrytesStatement(List hashes) throws Exception { final List elements = new LinkedList<>(); for (final String hash : hashes) { final TransactionViewModel transactionViewModel = TransactionViewModel.fromHash(instance.tangle, new Hash(hash)); @@ -397,6 +408,9 @@ private AbstractResponse getTrytesStatement(List hashes) throws Exceptio elements.add(Converter.trytes(transactionViewModel.trits())); } } + if (elements.size() > maxGetTrytes){ + return ErrorResponse.create("Could not complete request"); + } return GetTrytesResponse.create(elements); } @@ -566,7 +580,7 @@ private synchronized AbstractResponse findTransactionStatement(final Map) request.get("bundles")) { - if (!validTrytes(bundle, HASH_SIZE, ZERO_LENGTH_ALLOWED)) { + if (!validTrytes(bundle, HASH_SIZE, ZERO_LENGTH_NOT_ALLOWED)) { return ErrorResponse.create("Invalid bundle hash"); } bundlesTransactions.addAll(BundleViewModel.load(instance.tangle, new Hash(bundle)).getHashes()); @@ -579,7 +593,7 @@ private synchronized AbstractResponse findTransactionStatement(final Map a += ',' + b)); for (final String address : addresses) { - if (!validTrytes(address, HASH_SIZE, ZERO_LENGTH_ALLOWED)) { + if (!validTrytes(address, HASH_SIZE, ZERO_LENGTH_NOT_ALLOWED)) { return ErrorResponse.create("Invalid address input"); } addressesTransactions.addAll(AddressViewModel.load(instance.tangle, new Hash(address)).getHashes()); @@ -589,7 +603,7 @@ private synchronized AbstractResponse findTransactionStatement(final Map tagsTransactions = new HashSet<>(); if (request.containsKey("tags")) { for (String tag : (List) request.get("tags")) { - if (!validTrytes(tag,tag.length(), ZERO_LENGTH_ALLOWED)) { + if (!validTrytes(tag,tag.length(), ZERO_LENGTH_NOT_ALLOWED)) { return ErrorResponse.create("Invalid tag input"); } while (tag.length() < Curl.HASH_LENGTH / Converter.NUMBER_OF_TRITS_IN_A_TRYTE) { @@ -603,7 +617,7 @@ private synchronized AbstractResponse findTransactionStatement(final Map) request.get("approvees")) { - if (!validTrytes(approvee,HASH_SIZE, ZERO_LENGTH_ALLOWED)) { + if (!validTrytes(approvee,HASH_SIZE, ZERO_LENGTH_NOT_ALLOWED)) { return ErrorResponse.create("Invalid approvees hash"); } approveeTransactions.addAll(TransactionViewModel.fromHash(instance.tangle, new Hash(approvee)).getApprovers(instance.tangle).getHashes()); @@ -772,6 +786,7 @@ private AbstractResponse addNeighborsStatement(final List uris) throws U final URI uri = new URI(uriString); if ("udp".equals(uri.getScheme()) || "tcp".equals(uri.getScheme())) { + log.info("Adding neighbor: "+uriString); // 3rd parameter true if tcp, 4th parameter true (configured tethering) final Neighbor neighbor; switch(uri.getScheme()) { From 7ed8fe82cc77164878cc525e16df8da2c0288006 Mon Sep 17 00:00:00 2001 From: Alon Elmaliah Date: Mon, 12 Jun 2017 21:22:13 +0300 Subject: [PATCH 2/3] dev-1.2.1 (#163) * added debian packaging to pom * work in progress * updated pom * added plugin hash enforcement rules * fixed groupId in pom.xml * updated travis.yml * updated dependency-reduced.pom * updated verification hashes * restrict deploy to master/dev branches * added some white space to travis config * added input validation to depth & minWeightMagnitude enforce non empty array lists getTrytes limit added addNeighbor print --- .travis.yml | 18 +- Dockerfile | 2 +- changelog.txt | 3 + dependency-reduced-pom.xml | 125 ++++++++++++- pom.xml | 176 ++++++++++++++++-- src/deb/control/control | 14 ++ src/deb/control/postinst | 1 + src/deb/control/postrm | 1 + src/deb/control/preinst | 1 + src/deb/control/prerm | 1 + src/deb/init.d/iri | 0 src/main/java/com/iota/iri/IRI.java | 2 +- .../java/com/iota/iri/conf/Configuration.java | 2 + src/main/java/com/iota/iri/service/API.java | 33 +++- .../java/com/iota/iri/storage/Tangle.java | 1 - .../rocksDB/RocksDBPersistenceProvider.java | 4 + 16 files changed, 334 insertions(+), 50 deletions(-) create mode 100644 src/deb/control/control create mode 100644 src/deb/control/postinst create mode 100644 src/deb/control/postrm create mode 100644 src/deb/control/preinst create mode 100644 src/deb/control/prerm create mode 100644 src/deb/init.d/iri diff --git a/.travis.yml b/.travis.yml index eb3884fb6d..58997ae34d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,31 +7,33 @@ sudo: required #services: #- docker 000ctGQcXVGUjeURqQeHclLLpst2Td0uR6SgAGLEOxjeQ9ghzQWC/4x9BPW7xf7SkxhESWB2MMTvxma8xaV7hmNSsUK7tHyMLZPGdhDnPuUx2E6eNG4IZzUvcmHI4U= + before_install: - openssl aes-256-cbc -K $encrypted_5a15fa813cca_key -iv $encrypted_5a15fa813cca_iv -in codesigning.asc.enc -out codesigning.asc -d + before_script: gpg --fast-import codesigning.asc + script: mvn package -P build-extras + #after_success: #- openssl aes-256-cbc -K $encrypted_d7986c8d48fc_key -iv $encrypted_d7986c8d48fc_iv # -in .snapcraft/travis_snapcraft.cfg -out .snapcraft/snapcraft.cfg -d +# deploy: - provider: releases api_key: secure: l80FJQ+9Kk+ZYZxXcfagFGgnrp8BlnSZNCDv9KqbWYWQ4YL83qULlD1xgewUcEZhxbddR4nIo/gB1HxrdUxyjzHQKd1ysQ54BH9ZM51MqAtmzslz1gg6WNIDElugsY484W/ynAOQ286tq/5Y4bsAtmHaNzRLlf0sUfW1evXVBNFTz+0eLinqd/r0cC6bEFVk0TWXtk2+EcfTsowkyA36QNZhA+l0ti7GpJj5ubG4cd7hO7ktY4yQ130zJ4zrvv9aL6OwpFULGPDSV/wWujxcZm8GlLrJc2kWAHPLfQESt1Vr9ze2P/8n2FPyh9G67KemS8ubdp5XQPTZKALv4a7Zw8QBhJoahFptkqofgxQkDreCWlgwQyJvmfIJ7pFYXzGsdKUsd4aop6EhT44e2vJuYQBI+EUmx9HiW5+tQPsRkwWqyPyfchHu7KCpqGnImkDTjIHHJinB9dyEdQUbkGVVDWv3n8jNXas5IijS6YvMH5PVt6bWwcbAmijrY+a6E7kf/siJHNNyK/uBTL6FZIkkL2jcH6USgrt2KI/xIoBng1c1w000ctGQcXVGUjeURqQeHclLLpst2Td0uR6SgAGLEOxjeQ9ghzQWC/4x9BPW7xf7SkxhESWB2MMTvxma8xaV7hmNSsUK7tHyMLZPGdhDnPuUx2E6eNG4IZzUvcmHI4U= file_glob: true - file: - - "/home/travis/build/iotaledger/iri/target/iri*.jar" - - "/home/travis/build/iotaledger/iri/target/iri*.jar.asc" - - "/home/travis/build/iotaledger/iri/target/iri*-sources.jar" - - "/home/travis/build/iotaledger/iri/target/iri*-sources.jar.asc" - - "/home/travis/build/iotaledger/iri/target/iri*-javadoc.jar" - - "/home/travis/build/iotaledger/iri/target/iri*-javadoc.jar.asc" + file: target/*.jar* skip_cleanup: true on: tags: true repo: iotaledger/iri - all_branches: true + branch: + - master + - dev + #all_branches: true #- provider: script #script: docker run -v $(pwd):$(pwd) -t ubuntu:xenial sh -c "apt update -qq && apt #install snapcraft -y && cd $(pwd) && snapcraft && snapcraft push *.snap --release diff --git a/Dockerfile b/Dockerfile index 320b9f1f65..6cdff82765 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,3 @@ FROM java:8 -CMD ["/usr/bin/java", "-jar", "iri-1.2.0.jar"] +CMD ["/usr/bin/java", "-jar", "iri-1.2.1.jar"] diff --git a/changelog.txt b/changelog.txt index 75d921e07e..d7dfdc9f7e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +1.2.1 + - cleaner API messaging + 1.2.0 - Mainnet release with MWM 15 - Snapshot diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 8cc808a4a1..c075d7b4c6 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -1,11 +1,16 @@ 4.0.0 - groupId + com.iota iri - IRI Testnet - 1.2.0 - Testnet IOTA Reference Implementation + IRI + 1.2.1 + IOTA Reference Implementation + + scm:git:git://github.com/iotaledger/iri.git + scm:git:git@github.com/iotaledger/iri.git + https://github.com/iotaledger/iri/ + @@ -40,6 +45,49 @@ + + maven-enforcer-plugin + 1.4 + + + enforce + verify + + enforce + + + + + true + + org.apache.commons:commons-lang3:3.5:jar:null:compile:6c6c702c89bfff3cd9e80b04d668c5e190d588c6 + org.slf4j:slf4j-api:1.7.25:jar:null:compile:da76ca59f6a57ee3102f8f9bd9cee742973efa8a + ch.qos.logback:logback-classic:1.2.3:jar:null:compile:7c4f3c474fb2c041d8028740440937705ebb473a + commons-io:commons-io:2.5:jar:null:compile:2852e6e05fbb95076fc091f6d1780f1f8fe35e0f + org.rocksdb:rocksdbjni:5.1.4:jar:null:compile:1924f10f010ddf724a41d2ce6903a706bda7f1b6 + com.google.code.gson:gson:2.8.1:jar:null:compile:02a8e0aa38a2e21cb39e2f5a7d6704cbdc941da0 + io.undertow:undertow-core:${undertow.version}:jar:null:compile:e5764e5017bfe8c2dd421dc80035e5165501bfda + io.undertow:undertow-servlet:${undertow.version}:jar:null:compile:0e2850a558e70a2d72d9a3e782c7b6fde2d9f1c7 + io.undertow:undertow-websockets-jsr:${undertow.version}:jar:null:compile:a76941dade81de7847520755c2efc7fab67043cb + com.jayway.restassured:rest-assured:2.9.0:jar:null:test:d0d5b6720a58472ab99287c931a8205373d6e7b2 + com.jayway.jsonpath:json-path:2.2.0:jar:null:test:22290d17944bd239fabf5ac69005a60a7ecbbbcb + junit:junit:4.12:jar:null:test:2973d150c0dc1fefe998f834810d68f278ea58ec + org.ini4j:ini4j:0.5.4:jar:null:compile:4a3ee4146a90c619b20977d65951825f5675b560 + uk.co.froot.maven.enforcer:digest-enforcer-rules:0.0.1:jar:null:runtime:16a9e04f3fe4bb143c42782d07d5faf65b32106f + + + + + + + + + uk.co.froot.maven.enforcer + digest-enforcer-rules + 0.0.1 + + + @@ -49,7 +97,6 @@ maven-source-plugin - 3.0.1 attach-sources @@ -68,10 +115,6 @@ jar - - private - true - @@ -92,6 +135,68 @@ + + org.vafer + jdeb + 1.5 + + + package + + jdeb + + + true + true + USER + true + ${basedir}/src/deb/control + + + ${project.build.directory}/${project.build.finalName}.jar + file + + perm + /usr/share/iota/lib + loader + loader + + + + link + true + /usr/share/iota/iri.jar + /usr/share/iota/lib/${project.build.finalName}.jar + + + ${basedir}/src/deb/init.d + directory + + perm + /etc/init.d + loader + loader + + + + template + + etc/${project.artifactId} + var/lib/${project.artifactId} + var/log/${project.artifactId} + var/run/${project.artifactId} + + + perm + loader + loader + + + + + + + @@ -194,9 +299,9 @@ + 1.4.6.Final 1.8 UTF-8 - 1.4.6.Final diff --git a/pom.xml b/pom.xml index 8901993702..af9c17ad09 100644 --- a/pom.xml +++ b/pom.xml @@ -3,12 +3,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - groupId + com.iota iri - 1.2.0 + 1.2.1 - IRI Testnet - Testnet IOTA Reference Implementation + IRI + IOTA Reference Implementation https://github.com/iotaledger/iri/ @@ -19,7 +19,7 @@ 1.8 UTF-8 - 1.4.6.Final + 1.4.6.Final @@ -41,21 +41,21 @@ org.apache.commons commons-lang3 - 3.3.2 + 3.5 org.slf4j slf4j-api - 1.7.21 + 1.7.25 ch.qos.logback logback-classic - 1.1.7 + 1.2.3 @@ -65,43 +65,37 @@ 2.5 - - - org.reflections - reflections - 0.9.10 - - org.rocksdb rocksdbjni 5.1.4 + com.google.code.gson gson - 2.8.0 + 2.8.1 - + io.undertow undertow-core - ${undertown.version} + ${undertow.version} io.undertow undertow-servlet - ${undertown.version} + ${undertow.version} io.undertow undertow-websockets-jsr - ${undertown.version} + ${undertow.version} @@ -136,6 +130,13 @@ test + + uk.co.froot.maven.enforcer + digest-enforcer-rules + 0.0.1 + compile + + org.ini4j ini4j @@ -180,6 +181,69 @@ + + + org.apache.maven.plugins + maven-enforcer-plugin + 1.4 + + + enforce + verify + + enforce + + + + + + + true + + + + + + org.apache.commons:commons-lang3:3.5:jar:null:compile:6c6c702c89bfff3cd9e80b04d668c5e190d588c6 + + org.slf4j:slf4j-api:1.7.25:jar:null:compile:da76ca59f6a57ee3102f8f9bd9cee742973efa8a + ch.qos.logback:logback-classic:1.2.3:jar:null:compile:7c4f3c474fb2c041d8028740440937705ebb473a + commons-io:commons-io:2.5:jar:null:compile:2852e6e05fbb95076fc091f6d1780f1f8fe35e0f + org.rocksdb:rocksdbjni:5.1.4:jar:null:compile:1924f10f010ddf724a41d2ce6903a706bda7f1b6 + com.google.code.gson:gson:2.8.1:jar:null:compile:02a8e0aa38a2e21cb39e2f5a7d6704cbdc941da0 + io.undertow:undertow-core:${undertow.version}:jar:null:compile:e5764e5017bfe8c2dd421dc80035e5165501bfda + io.undertow:undertow-servlet:${undertow.version}:jar:null:compile:0e2850a558e70a2d72d9a3e782c7b6fde2d9f1c7 + io.undertow:undertow-websockets-jsr:${undertow.version}:jar:null:compile:a76941dade81de7847520755c2efc7fab67043cb + + com.jayway.restassured:rest-assured:2.9.0:jar:null:test:d0d5b6720a58472ab99287c931a8205373d6e7b2 + com.jayway.jsonpath:json-path:2.2.0:jar:null:test:22290d17944bd239fabf5ac69005a60a7ecbbbcb + junit:junit:4.12:jar:null:test:2973d150c0dc1fefe998f834810d68f278ea58ec + org.ini4j:ini4j:0.5.4:jar:null:compile:4a3ee4146a90c619b20977d65951825f5675b560 + + + uk.co.froot.maven.enforcer:digest-enforcer-rules:0.0.1:jar:null:runtime:16a9e04f3fe4bb143c42782d07d5faf65b32106f + + + + + + + + + + + + uk.co.froot.maven.enforcer + digest-enforcer-rules + 0.0.1 + + + + @@ -242,6 +306,78 @@ + + jdeb + org.vafer + 1.5 + + + package + + jdeb + + + + true + true + + USER + true + ${basedir}/src/deb/control + + + + ${project.build.directory}/${project.build.finalName}.jar + file + + perm + /usr/share/iota/lib + loader + loader + + + + + link + true + /usr/share/iota/iri.jar + /usr/share/iota/lib/${project.build.finalName}.jar + + + + ${basedir}/src/deb/init.d + directory + + perm + /etc/init.d + loader + loader + + + + + template + + etc/${project.artifactId} + var/lib/${project.artifactId} + var/log/${project.artifactId} + var/run/${project.artifactId} + + + perm + loader + loader + + + + + + + + diff --git a/src/deb/control/control b/src/deb/control/control new file mode 100644 index 0000000000..f9604e5482 --- /dev/null +++ b/src/deb/control/control @@ -0,0 +1,14 @@ +Package: [[name]] +Version: [[version]] +Section: misc +Priority: optional +Maintainer: Paul Handy +Build-Depends: maven (>= 3) +Depends: jdk (>= 1.8) +Standards-Version: 3.9.8 +Homepage: https://iota.org +Vcs-Git: https://github.com/iotaledger/iri.git +Vcs-Browser: https://github.com/iotaledger/iri.git +Architecture: any +Depends: default-jre | java8-runtime +Description: [[description]] diff --git a/src/deb/control/postinst b/src/deb/control/postinst new file mode 100644 index 0000000000..1a2485251c --- /dev/null +++ b/src/deb/control/postinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/src/deb/control/postrm b/src/deb/control/postrm new file mode 100644 index 0000000000..1a2485251c --- /dev/null +++ b/src/deb/control/postrm @@ -0,0 +1 @@ +#!/bin/sh diff --git a/src/deb/control/preinst b/src/deb/control/preinst new file mode 100644 index 0000000000..1a2485251c --- /dev/null +++ b/src/deb/control/preinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/src/deb/control/prerm b/src/deb/control/prerm new file mode 100644 index 0000000000..1a2485251c --- /dev/null +++ b/src/deb/control/prerm @@ -0,0 +1 @@ +#!/bin/sh diff --git a/src/deb/init.d/iri b/src/deb/init.d/iri new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/main/java/com/iota/iri/IRI.java b/src/main/java/com/iota/iri/IRI.java index afb7c9eaac..64cbdc20be 100644 --- a/src/main/java/com/iota/iri/IRI.java +++ b/src/main/java/com/iota/iri/IRI.java @@ -40,7 +40,7 @@ public class IRI { public static final String MAINNET_NAME = "IRI"; public static final String TESTNET_NAME = "IRI Testnet"; - public static final String VERSION = "1.2.0"; + public static final String VERSION = "1.2.1"; public static Iota iota; public static API api; public static IXI ixi; diff --git a/src/main/java/com/iota/iri/conf/Configuration.java b/src/main/java/com/iota/iri/conf/Configuration.java index f49841bcf2..1a0a615831 100644 --- a/src/main/java/com/iota/iri/conf/Configuration.java +++ b/src/main/java/com/iota/iri/conf/Configuration.java @@ -50,6 +50,7 @@ public enum DefaultConfSettings { RESCAN_DB, MAX_RANDOM_WALKS, MAX_FIND_TRANSACTIONS, + MAX_GET_TRYTES, MAX_DEPTH, MAINNET_MWM, TESTNET_MWM, @@ -89,6 +90,7 @@ public enum DefaultConfSettings { conf.put(DefaultConfSettings.MAX_DEPTH.name(), "15"); conf.put(DefaultConfSettings.MAX_FIND_TRANSACTIONS.name(), "100000"); + conf.put(DefaultConfSettings.MAX_GET_TRYTES.name(), "10000"); } diff --git a/src/main/java/com/iota/iri/service/API.java b/src/main/java/com/iota/iri/service/API.java index 19489476bc..9ff648f6a3 100644 --- a/src/main/java/com/iota/iri/service/API.java +++ b/src/main/java/com/iota/iri/service/API.java @@ -19,7 +19,6 @@ import java.util.Map; import java.util.Queue; import java.util.Set; -import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -97,6 +96,7 @@ public class API { private final int maxRandomWalks; private final int maxFindTxs; + private final int maxGetTrytes; private final static char ZERO_LENGTH_ALLOWED = 'Y'; private final static char ZERO_LENGTH_NOT_ALLOWED = 'N'; @@ -107,6 +107,7 @@ public API(Iota instance, IXI ixi) { this.ixi = ixi; maxRandomWalks = instance.configuration.integer(DefaultConfSettings.MAX_RANDOM_WALKS); maxFindTxs = instance.configuration.integer(DefaultConfSettings.MAX_FIND_TRANSACTIONS); + maxGetTrytes = instance.configuration.integer(DefaultConfSettings.MAX_GET_TRYTES); } @@ -201,7 +202,12 @@ private AbstractResponse process(final String requestString, InetSocketAddress s } final Hash trunkTransaction = new Hash((String) request.get("trunkTransaction")); final Hash branchTransaction = new Hash((String) request.get("branchTransaction")); - final int minWeightMagnitude = ((Double) request.get("minWeightMagnitude")).intValue(); + final int minWeightMagnitude; + try { + minWeightMagnitude = ((Double) request.get("minWeightMagnitude")).intValue(); + } catch (ClassCastException e) { + return ErrorResponse.create("Invalid minWeightMagnitude input"); + } final List trytes = (List) request.get("trytes"); for (final String tryt : trytes) { if (!validTrytes(tryt, TRYTES_SIZE, ZERO_LENGTH_NOT_ALLOWED)) { @@ -287,7 +293,12 @@ private AbstractResponse process(final String requestString, InetSocketAddress s return getTipsStatement(); } case "getTransactionsToApprove": { - final int depth = ((Double) request.get("depth")).intValue(); + final int depth; + try { + depth = ((Double) request.get("depth")).intValue(); + } catch (ClassCastException e) { + return ErrorResponse.create("Invalid depth input"); + } final Object referenceObj = request.get("reference"); final String reference = referenceObj == null? null: (String) referenceObj; if (invalidSubtangleStatus()) { @@ -311,7 +322,7 @@ private AbstractResponse process(final String requestString, InetSocketAddress s return ErrorResponse.create("Wrong arguments"); } for (final String hash : hashes) { - if (!validTrytes(hash, HASH_SIZE, ZERO_LENGTH_ALLOWED)) { + if (!validTrytes(hash, HASH_SIZE, ZERO_LENGTH_NOT_ALLOWED)) { return ErrorResponse.create("Invalid hash input"); } } @@ -389,7 +400,7 @@ private AbstractResponse removeNeighborsStatement(List uris) throws URIS return RemoveNeighborsResponse.create(numberOfRemovedNeighbors.get()); } - private AbstractResponse getTrytesStatement(List hashes) throws Exception { + private synchronized AbstractResponse getTrytesStatement(List hashes) throws Exception { final List elements = new LinkedList<>(); for (final String hash : hashes) { final TransactionViewModel transactionViewModel = TransactionViewModel.fromHash(instance.tangle, new Hash(hash)); @@ -397,6 +408,9 @@ private AbstractResponse getTrytesStatement(List hashes) throws Exceptio elements.add(Converter.trytes(transactionViewModel.trits())); } } + if (elements.size() > maxGetTrytes){ + return ErrorResponse.create("Could not complete request"); + } return GetTrytesResponse.create(elements); } @@ -566,7 +580,7 @@ private synchronized AbstractResponse findTransactionStatement(final Map) request.get("bundles")) { - if (!validTrytes(bundle, HASH_SIZE, ZERO_LENGTH_ALLOWED)) { + if (!validTrytes(bundle, HASH_SIZE, ZERO_LENGTH_NOT_ALLOWED)) { return ErrorResponse.create("Invalid bundle hash"); } bundlesTransactions.addAll(BundleViewModel.load(instance.tangle, new Hash(bundle)).getHashes()); @@ -579,7 +593,7 @@ private synchronized AbstractResponse findTransactionStatement(final Map a += ',' + b)); for (final String address : addresses) { - if (!validTrytes(address, HASH_SIZE, ZERO_LENGTH_ALLOWED)) { + if (!validTrytes(address, HASH_SIZE, ZERO_LENGTH_NOT_ALLOWED)) { return ErrorResponse.create("Invalid address input"); } addressesTransactions.addAll(AddressViewModel.load(instance.tangle, new Hash(address)).getHashes()); @@ -589,7 +603,7 @@ private synchronized AbstractResponse findTransactionStatement(final Map tagsTransactions = new HashSet<>(); if (request.containsKey("tags")) { for (String tag : (List) request.get("tags")) { - if (!validTrytes(tag,tag.length(), ZERO_LENGTH_ALLOWED)) { + if (!validTrytes(tag,tag.length(), ZERO_LENGTH_NOT_ALLOWED)) { return ErrorResponse.create("Invalid tag input"); } while (tag.length() < Curl.HASH_LENGTH / Converter.NUMBER_OF_TRITS_IN_A_TRYTE) { @@ -603,7 +617,7 @@ private synchronized AbstractResponse findTransactionStatement(final Map) request.get("approvees")) { - if (!validTrytes(approvee,HASH_SIZE, ZERO_LENGTH_ALLOWED)) { + if (!validTrytes(approvee,HASH_SIZE, ZERO_LENGTH_NOT_ALLOWED)) { return ErrorResponse.create("Invalid approvees hash"); } approveeTransactions.addAll(TransactionViewModel.fromHash(instance.tangle, new Hash(approvee)).getApprovers(instance.tangle).getHashes()); @@ -772,6 +786,7 @@ private AbstractResponse addNeighborsStatement(final List uris) throws U final URI uri = new URI(uriString); if ("udp".equals(uri.getScheme()) || "tcp".equals(uri.getScheme())) { + log.info("Adding neighbor: "+uriString); // 3rd parameter true if tcp, 4th parameter true (configured tethering) final Neighbor neighbor; switch(uri.getScheme()) { diff --git a/src/main/java/com/iota/iri/storage/Tangle.java b/src/main/java/com/iota/iri/storage/Tangle.java index ced9ef996b..f9a872074a 100644 --- a/src/main/java/com/iota/iri/storage/Tangle.java +++ b/src/main/java/com/iota/iri/storage/Tangle.java @@ -1,6 +1,5 @@ package com.iota.iri.storage; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.iota.iri.model.Hash; import com.iota.iri.model.Hashes; import com.iota.iri.utils.Pair; diff --git a/src/main/java/com/iota/iri/storage/rocksDB/RocksDBPersistenceProvider.java b/src/main/java/com/iota/iri/storage/rocksDB/RocksDBPersistenceProvider.java index 57a0a38470..ada9695b0f 100644 --- a/src/main/java/com/iota/iri/storage/rocksDB/RocksDBPersistenceProvider.java +++ b/src/main/java/com/iota/iri/storage/rocksDB/RocksDBPersistenceProvider.java @@ -194,6 +194,10 @@ public Persistable get(Class model, Indexable index) throws Exception { @Override public boolean mayExist(Class model, Indexable index) throws Exception { + /* for version 5.4.5 + ColumnFamilyHandle handle = classTreeMap.get().get(model); + return db.keyMayExist(handle, index.bytes(), new StringBuilder()); + */ return db.keyMayExist(classTreeMap.get().get(model), index.bytes(), new StringBuffer()); } From 2b74c2391737afe60210f7aaea561b648b78ddbf Mon Sep 17 00:00:00 2001 From: Paul D Handy Date: Mon, 12 Jun 2017 12:50:18 -0600 Subject: [PATCH 3/3] updated oauth token --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 58997ae34d..3b723c6223 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,8 @@ script: mvn package -P build-extras deploy: - provider: releases api_key: - secure: l80FJQ+9Kk+ZYZxXcfagFGgnrp8BlnSZNCDv9KqbWYWQ4YL83qULlD1xgewUcEZhxbddR4nIo/gB1HxrdUxyjzHQKd1ysQ54BH9ZM51MqAtmzslz1gg6WNIDElugsY484W/ynAOQ286tq/5Y4bsAtmHaNzRLlf0sUfW1evXVBNFTz+0eLinqd/r0cC6bEFVk0TWXtk2+EcfTsowkyA36QNZhA+l0ti7GpJj5ubG4cd7hO7ktY4yQ130zJ4zrvv9aL6OwpFULGPDSV/wWujxcZm8GlLrJc2kWAHPLfQESt1Vr9ze2P/8n2FPyh9G67KemS8ubdp5XQPTZKALv4a7Zw8QBhJoahFptkqofgxQkDreCWlgwQyJvmfIJ7pFYXzGsdKUsd4aop6EhT44e2vJuYQBI+EUmx9HiW5+tQPsRkwWqyPyfchHu7KCpqGnImkDTjIHHJinB9dyEdQUbkGVVDWv3n8jNXas5IijS6YvMH5PVt6bWwcbAmijrY+a6E7kf/siJHNNyK/uBTL6FZIkkL2jcH6USgrt2KI/xIoBng1c1w000ctGQcXVGUjeURqQeHclLLpst2Td0uR6SgAGLEOxjeQ9ghzQWC/4x9BPW7xf7SkxhESWB2MMTvxma8xaV7hmNSsUK7tHyMLZPGdhDnPuUx2E6eNG4IZzUvcmHI4U= + #secure: l80FJQ+9Kk+ZYZxXcfagFGgnrp8BlnSZNCDv9KqbWYWQ4YL83qULlD1xgewUcEZhxbddR4nIo/gB1HxrdUxyjzHQKd1ysQ54BH9ZM51MqAtmzslz1gg6WNIDElugsY484W/ynAOQ286tq/5Y4bsAtmHaNzRLlf0sUfW1evXVBNFTz+0eLinqd/r0cC6bEFVk0TWXtk2+EcfTsowkyA36QNZhA+l0ti7GpJj5ubG4cd7hO7ktY4yQ130zJ4zrvv9aL6OwpFULGPDSV/wWujxcZm8GlLrJc2kWAHPLfQESt1Vr9ze2P/8n2FPyh9G67KemS8ubdp5XQPTZKALv4a7Zw8QBhJoahFptkqofgxQkDreCWlgwQyJvmfIJ7pFYXzGsdKUsd4aop6EhT44e2vJuYQBI+EUmx9HiW5+tQPsRkwWqyPyfchHu7KCpqGnImkDTjIHHJinB9dyEdQUbkGVVDWv3n8jNXas5IijS6YvMH5PVt6bWwcbAmijrY+a6E7kf/siJHNNyK/uBTL6FZIkkL2jcH6USgrt2KI/xIoBng1c1w000ctGQcXVGUjeURqQeHclLLpst2Td0uR6SgAGLEOxjeQ9ghzQWC/4x9BPW7xf7SkxhESWB2MMTvxma8xaV7hmNSsUK7tHyMLZPGdhDnPuUx2E6eNG4IZzUvcmHI4U= + secure: "j+KolvRrsinh6OTqjli1y5I4gdPdD5MT6RFahVRrznxtcb2t7y6x41PknkI/8BksxLJKKQ1f40L307Aquzih9FmLesWcrYrCOS/B40dlCc3uV8DEZKhZF+QWqvsDpZ0EfiluGFljqGpxwngb/miNObqQzQvzpdUXBpZcuzxgqziynJD6jt3TYbNn544m/i4cWbb++b1h2Bm+jwELzJcf6/CZ1TxUh49vdM4S6yTpvnKwg4NLeH6g8s9oYEN1iwYtQokGKlH/emBZDsqDtF4KH7kXPpEKTcho4nH504XWJpanVAQ02Pha4SAnyVu4rKiLH4e6v99xZOBLVTH/qkvlwzvkNYr2xS5q9T9G7DZBRE+oc2MIbcnuSkhHwrUcmf2Hc0zCIP4RLCXAUuVlNEmIQUKgTezVzaqaEQLsa+EFIoosS+8pT/kVnaLbwxrITUmgM246+gvzMcVg8SmyPvVj6iRxfR6spTd7V2M0ePdqWlCL8P9RY4YrtxR2yJ6/3C0XNf29t+s/r1jat8fwWp8Gf7GiCaJEYG9VO24Chhi+MZCKBJnmx5G/98zvLw3f6a1FsEGZrw9RhF2vJKK6sD3rIvNkUsYmf0OhM7bf0NceFMGTJ/mFzM/JX0OHMtIyAvUfyyPVbQkIHNcGBgQMZasx07K3fjcn2lqv4FbHVi3HbdM=" file_glob: true file: target/*.jar* skip_cleanup: true