Skip to content

Commit

Permalink
replacedrule fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Dec 26, 2024
1 parent ce205f4 commit f6b801f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package sigma.validation

import sigma.VersionContext

/**
* Configuration of validation. Each `ValidationRule` instance should be
* implemented as an `object` to facilitate type-safe usage. It then should be
Expand Down Expand Up @@ -48,7 +50,11 @@ abstract class SigmaValidationSettings extends Iterable[(Short, (ValidationRule,
def isSoftFork(ruleId: Short, ve: ValidationException): Boolean = {
val infoOpt = get(ruleId)
infoOpt match {
case Some((_, ReplacedRule(_))) => true
case Some((vr, ReplacedRule(_))) => if (vr.id == 1011 && VersionContext.current.isV6Activated) {
false
} else {
true
}
case Some((rule, status)) => rule.isSoftFork(this, rule.id, status, ve.args)
case None => false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ object ValidationRules {
final def apply[T](objType: MethodsContainer, methodId: Byte): SMethod = {
checkRule()
val methodOpt = objType.getMethodById(methodId)
if (methodOpt.isDefined) methodOpt.get
else {
if (methodOpt.isDefined) {
methodOpt.get
} else {
throwValidationException(
new SerializerException(s"The method with code $methodId doesn't declared in the type $objType."),
Array[Any](objType, methodId))
Expand All @@ -130,7 +131,15 @@ object ValidationRules {
}
}

object CheckAndGetMethod extends CheckAndGetMethodTemplate(1011)
object CheckAndGetMethod extends CheckAndGetMethodTemplate(1011) {
override def isSoftFork(vs: SigmaValidationSettings,
ruleId: Short,
status: RuleStatus,
args: Seq[Any]): Boolean = {
false
}
}

object CheckAndGetMethodV6 extends CheckAndGetMethodTemplate(1016)

object CheckHeaderSizeBit extends ValidationRule(1012,
Expand Down

0 comments on commit f6b801f

Please sign in to comment.