Skip to content

Implement Semantic Boost Scoring for String Ranking #23

Closed

Description

@unclesp1d3r

Summary

Implement the semantic boost calculation component of the string ranking algorithm. This scoring system assigns boost values to strings based on their semantic meaning (URLs, file paths, GUIDs, etc.) to help prioritize the most valuable findings.

Background

The ranking algorithm combines multiple factors to produce a relevance score:

Final Score = SectionWeight + EncodingConfidence + SemanticBoost - NoisePenalty

This issue focuses on implementing the SemanticBoost component, which increases scores for strings that match known patterns indicating high analytical value.

Current State

  • ✅ Core data types defined (Tag enum, FoundString struct with score field)
  • ✅ Container parsers extract strings with semantic tags
  • ✅ Tag types defined: Url, Domain, IPv4, IPv6, FilePath, RegistryPath, Guid, Email, Base64, FormatString, UserAgent, Import, Export, Version, Manifest, Resource
  • ❌ No scoring implementation exists yet
  • ❌ Semantic boost calculation not implemented

Proposed Implementation

Base Boost Values by Tag Type

Create boost calculation based on tag categories:

Tag Category Boost Tags
Network +25 Url, Domain, IPv4, IPv6
Identifiers +20 Guid, Email
File System +15 FilePath, RegistryPath, UserAgent
Version/Manifest +12 Version, Manifest
Code Artifacts +10 FormatString, Base64
Symbols +8 Import, Export
Resources +5 Resource

Multi-Tag Bonuses

Strings with multiple semantic tags receive additional boosts with diminishing returns:

  • Additional bonus: (tags.len() - 1) * 3
  • Example: String with both Url and Domain tags gets base boost of 25 + 25 + 3 = 53

Context-Aware Adjustments

Apply contextual multipliers based on string source:

  1. High-value section boost: +20% for strings in StringData or Resources sections
  2. Symbol context boost: +5 for strings from ImportName or ExportName sources

Implementation Structure

Location: src/classification/ranking.rs

Key methods to implement:

  • calculate_semantic_boost() - Main entry point
  • calculate_base_boost() - Sum boost values for all tags
  • calculate_multi_tag_bonus() - Apply diminishing returns for multiple tags
  • get_tag_boost() - Return boost value for individual tag
  • apply_context_boost() - Apply source-based adjustments

Acceptance Criteria

  • calculate_semantic_boost() function implemented in src/classification/ranking.rs
  • All 15 tag types have correct boost values assigned
  • Multi-tag bonus calculation works correctly
  • Context-aware boost adjustments applied for import/export sources
  • Unit tests cover all tag types and combinations
  • Unit tests verify multi-tag bonus calculation
  • Unit tests verify context-aware adjustments
  • Edge cases tested: no tags, single tag, multiple tags
  • Documentation added with examples

Testing Requirements

Unit Tests Required

  1. Individual tag boosts: Test each tag type returns correct base value
  2. Multi-tag scenarios: Test combinations of 2, 3, 4+ tags
  3. Context adjustments: Test import/export source boosts
  4. Edge cases: Empty tag vector, single tag, maximum tag combination
  5. Configurable weights: Test custom boost configurations

Example Test Cases

  • URL tag should return boost of 25
  • URL + Domain tags should return 25 + 25 + 3 = 53
  • ImportName source should add +5 context boost
  • Empty tags vector should return 0
  • Single tag should have no multi-tag bonus

Dependencies

  • Blocked by: Ranking System Foundation - need RankingEngine struct and configuration
  • Related to: Classification module implementation
  • Enables: Complete ranking algorithm implementation

Technical Notes

  • Boost values are based on analytical value for malware analysis and binary reverse engineering
  • Network indicators (URLs, IPs) receive highest boost as they are often IoCs
  • Symbol names (imports/exports) are valuable for API usage analysis
  • Context-aware boosts help prioritize strings found in high-signal locations

Requirements

  • 5.2: Semantic boost calculation
  • 5.4: Import/export name boost scoring

References

  • Ranking Algorithm Documentation: docs/src/ranking.md
  • Implementation Plan: .kiro/specs/stringy-binary-analyzer/tasks.md - Task 11.2

Task-ID

stringy-analyzer/semantic-boost-scoring

Activity

  1. added this to the v0.1 milestone on Sep 30, 2025
  2. self-assigned this
    on Sep 30, 2025
  3. added theissue type on Nov 10, 2025
  4. unclesp1d3r commented on Nov 10, 2025

    @unclesp1d3r
    MemberAuthor

    @coderabbitai Enhance this issue body with additional context and a proposed solution. Improve the issue title and assign the proper labels and other metadata.

  5. changed the title [-]Semantic Boost Scoring[/-] [+]Implement Semantic Boost Scoring for String Ranking[/+] on Nov 10, 2025
  6. coderabbitai commented on Nov 10, 2025

    @coderabbitai
    Contributor

    Tip

    For best results, initiate chat on the files or code changes.

    🧩 Analysis chain

    🏁 Script executed:

    #!/bin/bash
    # Read the current issue details
    gh issue view 23 --json title,body,labels,assignees,milestone,state
    
    # Search for ranking-related code
    echo "=== Searching for ranking system code ==="
    rg -n --type=rust -C3 "rank|boost|score" -g '!target/**' -g '!**/test/**' | head -100
    
    # Search for tag types
    echo "=== Searching for tag types ==="
    rg -n --type=rust -C3 "Tag|TagType" -g '!target/**' | head -100
    
    # Find semantic-related code
    echo "=== Searching for semantic code ==="
    rg -n --type=rust -C3 "semantic" -g '!target/**' | head -50
    
    # Look for requirements documentation
    echo "=== Searching for requirements ==="
    fd -t f "requirement|spec|design" -e md -e txt
    
    # Check for existing boost or scoring implementations
    echo "=== Searching for boost/scoring implementations ==="
    ast-grep --pattern 'fn $_(boost: $_) {
      $$$
    }'
    

    Length of output: 3228


    🏁 Script executed:

    #!/bin/bash
    # Get complete Tag enum definition
    echo "=== Complete Tag enum definition ==="
    ast-grep --pattern 'pub enum Tag {
      $$$
    }'
    
    # Search for import/export related code
    echo "=== Searching for import/export code ==="
    rg -n --type=rust -C3 "Import|Export" -g '!target/**'
    
    # Look for StringSource definition
    echo "=== StringSource definition ==="
    ast-grep --pattern 'pub enum StringSource {
      $$$
    }'
    
    # Check for any existing scoring or ranking logic
    echo "=== Searching for scoring logic ==="
    rg -n --type=rust "score\s*=" -g '!target/**' -g '!**/test/**'
    
    # Look for requirements or design documents in the repo
    echo "=== Searching for documentation ==="
    fd -t f . -e md | head -20
    
    # Check README for context
    echo "=== README content ==="
    cat README.md 2>/dev/null || echo "No README.md found"
    

    Length of output: 22021


    🏁 Script executed:

    #!/bin/bash
    # Read the ranking documentation
    echo "=== Ranking Documentation ==="
    cat docs/src/ranking.md
    
    # Check for requirements or specifications
    echo -e "\n=== Looking for requirements documentation ==="
    cat concept.md
    
    # Check if there's a tasks or implementation plan
    echo -e "\n=== Looking for implementation plan ==="
    fd tasks.md
    cat .kiro/specs/stringy-binary-analyzer/tasks.md 2>/dev/null || echo "No tasks.md found in expected location"
    
    # Check for any existing test files that might give context
    echo -e "\n=== Checking for existing test structure ==="
    fd -t f test -e rs | head -10
    

    Length of output: 27700


    Final Score = SectionWeight + EncodingConfidence + SemanticBoost - NoisePenalty

    
    This issue focuses on implementing the **SemanticBoost** component, which increases scores for strings that match known patterns indicating high analytical value.
    
    ## Current State
    
    - ✅ Core data types defined (`Tag` enum, `FoundString` struct with `score` field)
    - ✅ Container parsers extract strings with semantic tags
    - ✅ Tag types defined: Url, Domain, IPv4, IPv6, FilePath, RegistryPath, Guid, Email, Base64, FormatString, UserAgent, Import, Export, Version, Manifest, Resource
    - ❌ No scoring implementation exists yet
    - ❌ Semantic boost calculation not implemented
    
    ## Proposed Implementation
    
    ### Base Boost Values by Tag Type
    
    Create boost calculation based on tag categories:
    
    | Tag Category | Boost | Tags |
    |-------------|-------|------|
    | Network | +25 | `Url`, `Domain`, `IPv4`, `IPv6` |
    | Identifiers | +20 | `Guid`, `Email` |
    | File System | +15 | `FilePath`, `RegistryPath`, `UserAgent` |
    | Version/Manifest | +12 | `Version`, `Manifest` |
    | Code Artifacts | +10 | `FormatString`, `Base64` |
    | Symbols | +8 | `Import`, `Export` |
    | Resources | +5 | `Resource` |
    
    ### Multi-Tag Bonuses
    
    Strings with multiple semantic tags receive additional boosts with diminishing returns:
    - Additional bonus: `(tags.len() - 1) * 3`
    - Example: String with both `Url` and `Domain` tags gets base boost of 25 + 25 + 3 = 53
    
    ### Context-Aware Adjustments
    
    Apply contextual multipliers based on string source:
    
    1. **High-value section boost**: +20% for strings in `StringData` or `Resources` sections
    2. **Symbol context boost**: +5 for strings from `ImportName` or `ExportName` sources
    
    ### Implementation Structure
    
    ```rust
    // src/classification/ranking.rs
    
    pub struct RankingEngine {
        config: RankingConfig,
    }
    
    impl RankingEngine {
        /// Calculate semantic boost for a string based on its tags and context
        pub fn calculate_semantic_boost(&self, tags: &[Tag], source: &StringSource) -> i32 {
            let base_boost = self.calculate_base_boost(tags);
            let multi_tag_bonus = self.calculate_multi_tag_bonus(tags);
            let context_boost = self.apply_context_boost(base_boost, source);
            
            base_boost + multi_tag_bonus + context_boost
        }
    
        fn calculate_base_boost(&self, tags: &[Tag]) -> i32 {
            tags.iter().map(|tag| self.get_tag_boost(tag)).sum()
        }
    
        fn calculate_multi_tag_bonus(&self, tags: &[Tag]) -> i32 {
            if tags.len() > 1 {
                (tags.len() as i32 - 1) * 3
            } else {
                0
            }
        }
    
        fn get_tag_boost(&self, tag: &Tag) -> i32 {
            match tag {
                Tag::Url | Tag::Domain | Tag::IPv4 | Tag::IPv6 => 25,
                Tag::Guid | Tag::Email => 20,
                Tag::FilePath | Tag::RegistryPath | Tag::UserAgent => 15,
                Tag::Version | Tag::Manifest => 12,
                Tag::FormatString | Tag::Base64 => 10,
                Tag::Import | Tag::Export => 8,
                Tag::Resource => 5,
            }
        }
    
        fn apply_context_boost(&self, base_boost: i32, source: &StringSource) -> i32 {
            match source {
                StringSource::ImportName | StringSource::ExportName => 5,
                _ => 0,
            }
        }
    }
    

    Acceptance Criteria

    • calculate_semantic_boost() function implemented in src/classification/ranking.rs
    • All 15 tag types have correct boost values assigned
    • Multi-tag bonus calculation works correctly
    • Context-aware boost adjustments applied for import/export sources
    • Unit tests cover all tag types and combinations
    • Unit tests verify multi-tag bonus calculation
    • Unit tests verify context-aware adjustments
    • Edge cases tested: no tags, single tag, multiple tags
    • Documentation added with examples

    Testing Requirements

    Unit Tests

    1. Individual tag boosts: Test each tag type returns correct base value
    2. Multi-tag scenarios: Test combinations of 2, 3, 4+ tags
    3. Context adjustments: Test import/export source boosts
    4. Edge cases:
      • Empty tag vector
      • Single tag (no multi-tag bonus)
      • Maximum tag combination
    5. Configurable weights: Test custom boost configurations

    Test Examples

    #[test]
    fn test_url_tag_boost() {
        let engine = RankingEngine::default();
        let tags = vec![Tag::Url];
        let boost = engine.calculate_base_boost(&tags);
        assert_eq!(boost, 25);
    }
    
    #[test]
    fn test_multi_tag_bonus() {
        let engine = RankingEngine::default();
        let tags = vec![Tag::Url, Tag::Domain];
        let bonus = engine.calculate_multi_tag_bonus(&tags);
        assert_eq!(bonus, 3); // (2-1) * 3
    }
    
    #[test]
    fn test_import_context_boost() {
        let engine = RankingEngine::default();
        let boost = engine.apply_context_boost(25, &StringSource::ImportName);
        assert_eq!(boost, 5);
    }

    Dependencies

    Technical Notes

    • Boost values are based on analytical value for malware analysis and binary reverse engineering
    • Network indicators (URLs, IPs) receive highest boost as they're often IoCs
    • Symbol names (imports/exports) are valuable for API usage analysis
    • Context-aware boosts help prioritize strings found in high-signal locations

    Requirements

    • 5.2: Semantic boost calculation
    • 5.4: Import/export name boost scoring

    References

    Task-ID

    stringy-analyzer/semantic-boost-scoring
    EOF

    Update the issue

    gh issue edit 23
    --title "$TITLE"
    --body "$BODY"

    echo "Issue #23 updated successfully"

    
    ---
    
    🏁 Script executed:
    

    #!/bin/bash

    Update the issue with enhanced content

    Enhanced title

    TITLE="Implement Semantic Boost Scoring for String Ranking"

    Enhanced body with comprehensive context

    read -r -d '' BODY << 'EOF'

    Summary

    Implement the semantic boost calculation component of the string ranking algorithm. This scoring system assigns boost values to strings based on their semantic meaning (URLs, file paths, GUIDs, etc.) to help prioritize the most valuable findings.

    Background

    The ranking algorithm combines multiple factors to produce a relevance score:

    
    Length of output: 92
    
    ---
    
    Final Score = SectionWeight + EncodingConfidence + SemanticBoost - NoisePenalty
    

    This issue focuses on implementing the SemanticBoost component, which increases scores for strings that match known patterns indicating high analytical value.

    Current State

    • ✅ Core data types defined (Tag enum, FoundString struct with score field)
    • ✅ Container parsers extract strings with semantic tags
    • ✅ Tag types defined: Url, Domain, IPv4, IPv6, FilePath, RegistryPath, Guid, Email, Base64, FormatString, UserAgent, Import, Export, Version, Manifest, Resource
    • ❌ No scoring implementation exists yet
    • ❌ Semantic boost calculation not implemented

    Proposed Implementation

    Base Boost Values by Tag Type

    Create boost calculation based on tag categories:

    Tag Category Boost Tags
    Network +25 Url, Domain, IPv4, IPv6
    Identifiers +20 Guid, Email
    File System +15 FilePath, RegistryPath, UserAgent
    Version/Manifest +12 Version, Manifest
    Code Artifacts +10 FormatString, Base64
    Symbols +8 Import, Export
    Resources +5 Resource

    Multi-Tag Bonuses

    Strings with multiple semantic tags receive additional boosts with diminishing returns:

    • Additional bonus: (tags.len() - 1) * 3
    • Example: String with both Url and Domain tags gets base boost of 25 + 25 + 3 = 53

    Context-Aware Adjustments

    Apply contextual multipliers based on string source:

    1. High-value section boost: +20% for strings in StringData or Resources sections
    2. Symbol context boost: +5 for strings from ImportName or ExportName sources

    Implementation Structure

    // src/classification/ranking.rs
    
    pub struct RankingEngine {
        config: RankingConfig,
    }
    
    impl RankingEngine {
        /// Calculate semantic boost for a string based on its tags and context
        pub fn calculate_semantic_boost(&self, tags: &[Tag], source: &StringSource) -> i32 {
            let base_boost = self.calculate_base_boost(tags);
            let multi_tag_bonus = self.calculate_multi_tag_bonus(tags);
            let context_boost = self.apply_context_boost(base_boost, source);
            
            base_boost + multi_tag_bonus + context_boost
        }
    
        fn calculate_base_boost(&self, tags: &[Tag]) -> i32 {
            tags.iter().map(|tag| self.get_tag_boost(tag)).sum()
        }
    
        fn calculate_multi_tag_bonus(&self, tags: &[Tag]) -> i32 {
            if tags.len() > 1 {
                (tags.len() as i32 - 1) * 3
            } else {
                0
            }
        }
    
        fn get_tag_boost(&self, tag: &Tag) -> i32 {
            match tag {
                Tag::Url | Tag::Domain | Tag::IPv4 | Tag::IPv6 => 25,
                Tag::Guid | Tag::Email => 20,
                Tag::FilePath | Tag::RegistryPath | Tag::UserAgent => 15,
                Tag::Version | Tag::Manifest => 12,
                Tag::FormatString | Tag::Base64 => 10,
                Tag::Import | Tag::Export => 8,
                Tag::Resource => 5,
            }
        }
    
        fn apply_context_boost(&self, base_boost: i32, source: &StringSource) -> i32 {
            match source {
                StringSource::ImportName | StringSource::ExportName => 5,
                _ => 0,
            }
        }
    }

    Acceptance Criteria

    • calculate_semantic_boost() function implemented in src/classification/ranking.rs
    • All 15 tag types have correct boost values assigned
    • Multi-tag bonus calculation works correctly
    • Context-aware boost adjustments applied for import/export sources
    • Unit tests cover all tag types and combinations
    • Unit tests verify multi-tag bonus calculation
    • Unit tests verify context-aware adjustments
    • Edge cases tested: no tags, single tag, multiple tags
    • Documentation added with examples

    Testing Requirements

    Unit Tests

    1. Individual tag boosts: Test each tag type returns correct base value
    2. Multi-tag scenarios: Test combinations of 2, 3, 4+ tags
    3. Context adjustments: Test import/export source boosts
    4. Edge cases:
      • Empty tag vector
      • Single tag (no multi-tag bonus)
      • Maximum tag combination
    5. Configurable weights: Test custom boost configurations

    Test Examples

    #[test]
    fn test_url_tag_boost() {
        let engine = RankingEngine::default();
        let tags = vec![Tag::Url];
        let boost = engine.calculate_base_boost(&tags);
        assert_eq!(boost, 25);
    }
    
    #[test]
    fn test_multi_tag_bonus() {
        let engine = RankingEngine::default();
        let tags = vec![Tag::Url, Tag::Domain];
        let bonus = engine.calculate_multi_tag_bonus(&tags);
        assert_eq!(bonus, 3); // (2-1) * 3
    }
    
    #[test]
    fn test_import_context_boost() {
        let engine = RankingEngine::default();
        let boost = engine.apply_context_boost(25, &StringSource::ImportName);
        assert_eq!(boost, 5);
    }

    Dependencies

    • Blocked by: Ranking System Foundation - need RankingEngine struct and configuration
    • Related to: Classification module implementation
    • Enables: Complete ranking algorithm implementation

    Technical Notes

    • Boost values are based on analytical value for malware analysis and binary reverse engineering
    • Network indicators (URLs, IPs) receive highest boost as they're often IoCs
    • Symbol names (imports/exports) are valuable for API usage analysis
    • Context-aware boosts help prioritize strings found in high-signal locations

    Requirements

    • 5.2: Semantic boost calculation
    • 5.4: Import/export name boost scoring

    References

    Task-ID

    stringy-analyzer/semantic-boost-scoring
    ENDOFFILE

    Update the issue with the new title and body

    gh issue edit 23
    --title "Implement Semantic Boost Scoring for String Ranking"
    --body-file /tmp/issue_body.md

    echo "✓ Issue title and body updated"

    Add priority:high label if not already present

    gh issue edit 23 --add-label "priority:high"

    echo "✓ Labels updated"

    Show the updated issue

    echo ""
    echo "=== Updated Issue ==="
    gh issue view 23

    
    ---
    
    🏁 Script executed:
    

    #!/bin/bash

    Create enhanced issue body in a temporary file

    cat > /tmp/issue_body.md << 'ENDOFFILE'

    Summary

    Implement the semantic boost calculation component of the string ranking algorithm. This scoring system assigns boost values to strings based on their semantic meaning (URLs, file paths, GUIDs, etc.) to help prioritize the most valuable findings.

    Background

    The ranking algorithm combines multiple factors to produce a relevance score:

    
    Length of output: 98
    
    ---
    
    Final Score = SectionWeight + EncodingConfidence + SemanticBoost - NoisePenalty
    

    This issue focuses on implementing the SemanticBoost component, which increases scores for strings that match known patterns indicating high analytical value.

    Current State

    • ✅ Core data types defined (Tag enum, FoundString struct with score field)
    • ✅ Container parsers extract strings with semantic tags
    • ✅ Tag types defined: Url, Domain, IPv4, IPv6, FilePath, RegistryPath, Guid, Email, Base64, FormatString, UserAgent, Import, Export, Version, Manifest, Resource
    • ❌ No scoring implementation exists yet
    • ❌ Semantic boost calculation not implemented

    Proposed Implementation

    Base Boost Values by Tag Type

    Create boost calculation based on tag categories:

    Tag Category Boost Tags
    Network +25 Url, Domain, IPv4, IPv6
    Identifiers +20 Guid, Email
    File System +15 FilePath, RegistryPath, UserAgent
    Version/Manifest +12 Version, Manifest
    Code Artifacts +10 FormatString, Base64
    Symbols +8 Import, Export
    Resources +5 Resource

    Multi-Tag Bonuses

    Strings with multiple semantic tags receive additional boosts with diminishing returns:

    • Additional bonus: (tags.len() - 1) * 3
    • Example: String with both Url and Domain tags gets base boost of 25 + 25 + 3 = 53

    Context-Aware Adjustments

    Apply contextual multipliers based on string source:

    1. High-value section boost: +20% for strings in StringData or Resources sections
    2. Symbol context boost: +5 for strings from ImportName or ExportName sources

    Implementation Structure

    // src/classification/ranking.rs
    
    pub struct RankingEngine {
        config: RankingConfig,
    }
    
    impl RankingEngine {
        /// Calculate semantic boost for a string based on its tags and context
        pub fn calculate_semantic_boost(&self, tags: &[Tag], source: &StringSource) -> i32 {
            let base_boost = self.calculate_base_boost(tags);
            let multi_tag_bonus = self.calculate_multi_tag_bonus(tags);
            let context_boost = self.apply_context_boost(base_boost, source);
            
            base_boost + multi_tag_bonus + context_boost
        }
    
        fn calculate_base_boost(&self, tags: &[Tag]) -> i32 {
            tags.iter().map(|tag| self.get_tag_boost(tag)).sum()
        }
    
        fn calculate_multi_tag_bonus(&self, tags: &[Tag]) -> i32 {
            if tags.len() > 1 {
                (tags.len() as i32 - 1) * 3
            } else {
                0
            }
        }
    
        fn get_tag_boost(&self, tag: &Tag) -> i32 {
            match tag {
                Tag::Url | Tag::Domain | Tag::IPv4 | Tag::IPv6 => 25,
                Tag::Guid | Tag::Email => 20,
                Tag::FilePath | Tag::RegistryPath | Tag::UserAgent => 15,
                Tag::Version | Tag::Manifest => 12,
                Tag::FormatString | Tag::Base64 => 10,
                Tag::Import | Tag::Export => 8,
                Tag::Resource => 5,
            }
        }
    
        fn apply_context_boost(&self, base_boost: i32, source: &StringSource) -> i32 {
            match source {
                StringSource::ImportName | StringSource::ExportName => 5,
                _ => 0,
            }
        }
    }

    Acceptance Criteria

    • calculate_semantic_boost() function implemented in src/classification/ranking.rs
    • All 15 tag types have correct boost values assigned
    • Multi-tag bonus calculation works correctly
    • Context-aware boost adjustments applied for import/export sources
    • Unit tests cover all tag types and combinations
    • Unit tests verify multi-tag bonus calculation
    • Unit tests verify context-aware adjustments
    • Edge cases tested: no tags, single tag, multiple tags
    • Documentation added with examples

    Testing Requirements

    Unit Tests

    1. Individual tag boosts: Test each tag type returns correct base value
    2. Multi-tag scenarios: Test combinations of 2, 3, 4+ tags
    3. Context adjustments: Test import/export source boosts
    4. Edge cases:
      • Empty tag vector
      • Single tag (no multi-tag bonus)
      • Maximum tag combination
    5. Configurable weights: Test custom boost configurations

    Test Examples

    #[test]
    fn test_url_tag_boost() {
        let engine = RankingEngine::default();
        let tags = vec![Tag::Url];
        let boost = engine.calculate_base_boost(&tags);
        assert_eq!(boost, 25);
    }
    
    #[test]
    fn test_multi_tag_bonus() {
        let engine = RankingEngine::default();
        let tags = vec![Tag::Url, Tag::Domain];
        let bonus = engine.calculate_multi_tag_bonus(&tags);
        assert_eq!(bonus, 3); // (2-1) * 3
    }
    
    #[test]
    fn test_import_context_boost() {
        let engine = RankingEngine::default();
        let boost = engine.apply_context_boost(25, &StringSource::ImportName);
        assert_eq!(boost, 5);
    }

    Dependencies

    • Blocked by: Ranking System Foundation - need RankingEngine struct and configuration
    • Related to: Classification module implementation
    • Enables: Complete ranking algorithm implementation

    Technical Notes

    • Boost values are based on analytical value for malware analysis and binary reverse engineering
    • Network indicators (URLs, IPs) receive highest boost as they're often IoCs
    • Symbol names (imports/exports) are valuable for API usage analysis
    • Context-aware boosts help prioritize strings found in high-signal locations

    Requirements

    • 5.2: Semantic boost calculation
    • 5.4: Import/export name boost scoring

    References

    Task-ID

    stringy-analyzer/semantic-boost-scoring
    """

    Write to temp file

    with open('/tmp/issue_body.txt', 'w') as f:
    f.write(issue_body)

    print("Issue body file created successfully")
    PYTHONEOF

    Now update the issue using the file

    gh issue edit 23
    --title "Implement Semantic Boost Scoring for String Ranking"
    --body-file /tmp/issue_body.txt

    echo ""
    echo "✓ Issue #23 updated with enhanced title and body"

    Add priority:high label

    gh issue edit 23 --add-label "priority:high" 2>/dev/null || echo "Note: priority:high label may not exist or is already applied"

    echo "✓ Attempted to add priority:high label"

    Display the updated issue

    echo ""
    echo "=== Updated Issue Preview ==="
    gh issue view 23 --json title,body,labels,assignees | jq -r '
    "Title: (.title)\n",
    "Labels: (.labels | map(.name) | join(", "))\n",
    "Assignees: (.assignees | map(.login) | join(", "))\n",
    "Body (first 500 chars):\n(.body[0:500])..."
    '

    
    ---
    
    🏁 Script executed:
    

    #!/bin/bash

    Create the enhanced issue body using Python to avoid here-doc issues

    python3 << 'PYTHONEOF'
    import subprocess
    import json

    issue_body = """## Summary

    Implement the semantic boost calculation component of the string ranking algorithm. This scoring system assigns boost values to strings based on their semantic meaning (URLs, file paths, GUIDs, etc.) to help prioritize the most valuable findings.

    Background

    The ranking algorithm combines multiple factors to produce a relevance score:

    
    Length of output: 250
    
    ---
    
    Final Score = SectionWeight + EncodingConfidence + SemanticBoost - NoisePenalty
    

    This issue focuses on implementing the SemanticBoost component, which increases scores for strings that match known patterns indicating high analytical value.

    Current State

    • ✅ Core data types defined (Tag enum, FoundString struct with score field)
    • ✅ Container parsers extract strings with semantic tags
    • ✅ Tag types defined: Url, Domain, IPv4, IPv6, FilePath, RegistryPath, Guid, Email, Base64, FormatString, UserAgent, Import, Export, Version, Manifest, Resource
    • ❌ No scoring implementation exists yet
    • ❌ Semantic boost calculation not implemented

    Proposed Implementation

    Base Boost Values by Tag Type

    Create boost calculation based on tag categories:

    Tag Category Boost Tags
    Network +25 Url, Domain, IPv4, IPv6
    Identifiers +20 Guid, Email
    File System +15 FilePath, RegistryPath, UserAgent
    Version/Manifest +12 Version, Manifest
    Code Artifacts +10 FormatString, Base64
    Symbols +8 Import, Export
    Resources +5 Resource

    Multi-Tag Bonuses

    Strings with multiple semantic tags receive additional boosts with diminishing returns:

    • Additional bonus: (tags.len() - 1) * 3
    • Example: String with both Url and Domain tags gets base boost of 25 + 25 + 3 = 53

    Context-Aware Adjustments

    Apply contextual multipliers based on string source:

    1. High-value section boost: +20% for strings in StringData or Resources sections
    2. Symbol context boost: +5 for strings from ImportName or ExportName sources

    Implementation Structure

    // src/classification/ranking.rs
    
    pub struct RankingEngine {
        config: RankingConfig,
    }
    
    impl RankingEngine {
        /// Calculate semantic boost for a string based on its tags and context
        pub fn calculate_semantic_boost(&self, tags: &[Tag], source: &StringSource) -> i32 {
            let base_boost = self.calculate_base_boost(tags);
            let multi_tag_bonus = self.calculate_multi_tag_bonus(tags);
            let context_boost = self.apply_context_boost(base_boost, source);
            
            base_boost + multi_tag_bonus + context_boost
        }
    
        fn calculate_base_boost(&self, tags: &[Tag]) -> i32 {
            tags.iter().map(|tag| self.get_tag_boost(tag)).sum()
        }
    
        fn calculate_multi_tag_bonus(&self, tags: &[Tag]) -> i32 {
            if tags.len() > 1 {
                (tags.len() as i32 - 1) * 3
            } else {
                0
            }
        }
    
        fn get_tag_boost(&self, tag: &Tag) -> i32 {
            match tag {
                Tag::Url | Tag::Domain | Tag::IPv4 | Tag::IPv6 => 25,
                Tag::Guid | Tag::Email => 20,
                Tag::FilePath | Tag::RegistryPath | Tag::UserAgent => 15,
                Tag::Version | Tag::Manifest => 12,
                Tag::FormatString | Tag::Base64 => 10,
                Tag::Import | Tag::Export => 8,
                Tag::Resource => 5,
            }
        }
    
        fn apply_context_boost(&self, base_boost: i32, source: &StringSource) -> i32 {
            match source {
                StringSource::ImportName | StringSource::ExportName => 5,
                _ => 0,
            }
        }
    }

    Acceptance Criteria

    • calculate_semantic_boost() function implemented in src/classification/ranking.rs
    • All 15 tag types have correct boost values assigned
    • Multi-tag bonus calculation works correctly
    • Context-aware boost adjustments applied for import/export sources
    • Unit tests cover all tag types and combinations
    • Unit tests verify multi-tag bonus calculation
    • Unit tests verify context-aware adjustments
    • Edge cases tested: no tags, single tag, multiple tags
    • Documentation added with examples

    Testing Requirements

    Unit Tests

    1. Individual tag boosts: Test each tag type returns correct base value
    2. Multi-tag scenarios: Test combinations of 2, 3, 4+ tags
    3. Context adjustments: Test import/export source boosts
    4. Edge cases: Empty tag vector, Single tag (no multi-tag bonus), Maximum tag combination
    5. Configurable weights: Test custom boost configurations

    Dependencies

    • Blocked by: Ranking System Foundation - need RankingEngine struct and configuration
    • Related to: Classification module implementation
    • Enables: Complete ranking algorithm implementation

    Technical Notes

    • Boost values are based on analytical value for malware analysis and binary reverse engineering
    • Network indicators (URLs, IPs) receive highest boost as they are often IoCs
    • Symbol names (imports/exports) are valuable for API usage analysis
    • Context-aware boosts help prioritize strings found in high-signal locations

    Requirements

    • 5.2: Semantic boost calculation
    • 5.4: Import/export name boost scoring

    References

    Task-ID

    stringy-analyzer/semantic-boost-scoring'

    echo ""
    echo "✓ Issue #23 title and body updated successfully"
    echo ""

    Try to add priority:high label

    gh issue edit 23 --add-label "priority:high" 2>&1 || echo "Note: Could not add priority:high label (may not exist)"

    echo ""
    echo "=== Viewing Updated Issue ==="
    gh issue view 23

    
    ---
    
    🏁 Script executed:
    

    #!/bin/bash

    Write the issue body directly using gh issue edit with --body flag

    gh issue edit 23
    --title "Implement Semantic Boost Scoring for String Ranking"
    --body '## Summary

    Implement the semantic boost calculation component of the string ranking algorithm. This scoring system assigns boost values to strings based on their semantic meaning (URLs, file paths, GUIDs, etc.) to help prioritize the most valuable findings.

    Background

    The ranking algorithm combines multiple factors to produce a relevance score:

    
    Length of output: 68
    
    ---
    
    Final Score = SectionWeight + EncodingConfidence + SemanticBoost - NoisePenalty
    

    This issue focuses on implementing the SemanticBoost component, which increases scores for strings that match known patterns indicating high analytical value.

    Current State

    • ✅ Core data types defined (Tag enum, FoundString struct with score field)
    • ✅ Container parsers extract strings with semantic tags
    • ✅ Tag types defined: Url, Domain, IPv4, IPv6, FilePath, RegistryPath, Guid, Email, Base64, FormatString, UserAgent, Import, Export, Version, Manifest, Resource
    • ❌ No scoring implementation exists yet
    • ❌ Semantic boost calculation not implemented

    Proposed Implementation

    Base Boost Values by Tag Type

    Create boost calculation based on tag categories:

    Tag Category Boost Tags
    Network +25 Url, Domain, IPv4, IPv6
    Identifiers +20 Guid, Email
    File System +15 FilePath, RegistryPath, UserAgent
    Version/Manifest +12 Version, Manifest
    Code Artifacts +10 FormatString, Base64
    Symbols +8 Import, Export
    Resources +5 Resource

    Multi-Tag Bonuses

    Strings with multiple semantic tags receive additional boosts with diminishing returns:

    • Additional bonus: (tags.len() - 1) * 3
    • Example: String with both Url and Domain tags gets base boost of 25 + 25 + 3 = 53

    Context-Aware Adjustments

    Apply contextual multipliers based on string source:

    1. High-value section boost: +20% for strings in StringData or Resources sections
    2. Symbol context boost: +5 for strings from ImportName or ExportName sources

    Implementation Structure

    Location: src/classification/ranking.rs

    Key methods to implement:

    • calculate_semantic_boost() - Main entry point
    • calculate_base_boost() - Sum boost values for all tags
    • calculate_multi_tag_bonus() - Apply diminishing returns for multiple tags
    • get_tag_boost() - Return boost value for individual tag
    • apply_context_boost() - Apply source-based adjustments

    Acceptance Criteria

    • calculate_semantic_boost() function implemented in src/classification/ranking.rs
    • All 15 tag types have correct boost values assigned
    • Multi-tag bonus calculation works correctly
    • Context-aware boost adjustments applied for import/export sources
    • Unit tests cover all tag types and combinations
    • Unit tests verify multi-tag bonus calculation
    • Unit tests verify context-aware adjustments
    • Edge cases tested: no tags, single tag, multiple tags
    • Documentation added with examples

    Testing Requirements

    Unit Tests Required

    1. Individual tag boosts: Test each tag type returns correct base value
    2. Multi-tag scenarios: Test combinations of 2, 3, 4+ tags
    3. Context adjustments: Test import/export source boosts
    4. Edge cases: Empty tag vector, single tag, maximum tag combination
    5. Configurable weights: Test custom boost configurations

    Example Test Cases

    • URL tag should return boost of 25
    • URL + Domain tags should return 25 + 25 + 3 = 53
    • ImportName source should add +5 context boost
    • Empty tags vector should return 0
    • Single tag should have no multi-tag bonus

    Dependencies

    • Blocked by: Ranking System Foundation - need RankingEngine struct and configuration
    • Related to: Classification module implementation
    • Enables: Complete ranking algorithm implementation

    Technical Notes

    • Boost values are based on analytical value for malware analysis and binary reverse engineering
    • Network indicators (URLs, IPs) receive highest boost as they are often IoCs
    • Symbol names (imports/exports) are valuable for API usage analysis
    • Context-aware boosts help prioritize strings found in high-signal locations

    Requirements

    • 5.2: Semantic boost calculation
    • 5.4: Import/export name boost scoring

    References

    • Ranking Algorithm Documentation: docs/src/ranking.md
    • Implementation Plan: .kiro/specs/stringy-binary-analyzer/tasks.md - Task 11.2

    Task-ID

    stringy-analyzer/semantic-boost-scoring
    EOF

    Update the issue

    gh issue edit 23 --title "Implement Semantic Boost Scoring for String Ranking" --body-file /tmp/issue23.md

    echo "Issue #23 updated successfully!"
    echo ""

    Try to add priority label

    gh issue edit 23 --add-label "priority:high" 2>&1 | grep -v "label.*does not exist" || true

    echo ""
    echo "=== Updated Issue Preview ==="
    gh issue view 23 --json title,labels,assignees,body | jq -r '"Title: " + .title, "Labels: " + (.labels | map(.name) | join(", ")), "Assignees: " + (.assignees | map(.login) | join(", ")), "", "Body preview:", (.body | .[0:600]) + "..."'

    
    ---
    
    🏁 Script executed:
    

    #!/bin/bash

    Create issue body in a file

    cat > /tmp/issue23.md << 'EOF'

    Summary

    Implement the semantic boost calculation component of the string ranking algorithm. This scoring system assigns boost values to strings based on their semantic meaning (URLs, file paths, GUIDs, etc.) to help prioritize the most valuable findings.

    Background

    The ranking algorithm combines multiple factors to produce a relevance score:

    
    Length of output: 92
    
    ---
    
    🏁 Script executed:
    

    #!/bin/bash

    Create issue body using multiple echo statements to avoid here-doc issues

    {
    echo "## Summary"
    echo ""
    echo "Implement the semantic boost calculation component of the string ranking algorithm. This scoring system assigns boost values to strings based on their semantic meaning (URLs, file paths, GUIDs, etc.) to help prioritize the most valuable findings."
    echo ""
    echo "## Background"
    echo ""
    echo "The ranking algorithm combines multiple factors to produce a relevance score:"
    echo ""
    echo '' echo "Final Score = SectionWeight + EncodingConfidence + SemanticBoost - NoisePenalty" echo ''
    echo ""
    echo "This issue focuses on implementing the SemanticBoost component, which increases scores for strings that match known patterns indicating high analytical value."
    echo ""
    echo "## Current State"
    echo ""
    echo "- ✅ Core data types defined (Tag enum, FoundString struct with score field)"
    echo "- ✅ Container parsers extract strings with semantic tags"
    echo "- ✅ Tag types defined: Url, Domain, IPv4, IPv6, FilePath, RegistryPath, Guid, Email, Base64, FormatString, UserAgent, Import, Export, Version, Manifest, Resource"
    echo "- ❌ No scoring implementation exists yet"
    echo "- ❌ Semantic boost calculation not implemented"
    echo ""
    echo "## Proposed Implementation"
    echo ""
    echo "### Base Boost Values by Tag Type"
    echo ""
    echo "Create boost calculation based on tag categories:"
    echo ""
    echo "| Tag Category | Boost | Tags |"
    echo "|-------------|-------|------|"
    echo "| Network | +25 | Url, Domain, IPv4, IPv6 |"
    echo "| Identifiers | +20 | Guid, Email |"
    echo "| File System | +15 | FilePath, RegistryPath, UserAgent |"
    echo "| Version/Manifest | +12 | Version, Manifest |"
    echo "| Code Artifacts | +10 | FormatString, Base64 |"
    echo "| Symbols | +8 | Import, Export |"
    echo "| Resources | +5 | Resource |"
    echo ""
    echo "### Multi-Tag Bonuses"
    echo ""
    echo "Strings with multiple semantic tags receive additional boosts with diminishing returns:"
    echo "- Additional bonus: (tags.len() - 1) * 3"
    echo "- Example: String with both Url and Domain tags gets base boost of 25 + 25 + 3 = 53"
    echo ""
    echo "### Context-Aware Adjustments"
    echo ""
    echo "Apply contextual multipliers based on string source:"
    echo ""
    echo "1. High-value section boost: +20% for strings in StringData or Resources sections"
    echo "2. Symbol context boost: +5 for strings from ImportName or ExportName sources"
    echo ""
    echo "### Implementation Structure"
    echo ""
    echo "Location: src/classification/ranking.rs"
    echo ""
    echo "Key methods to implement:"
    echo "- calculate_semantic_boost() - Main entry point"
    echo "- calculate_base_boost() - Sum boost values for all tags"
    echo "- calculate_multi_tag_bonus() - Apply diminishing returns for multiple tags"
    echo "- get_tag_boost() - Return boost value for individual tag"
    echo "- apply_context_boost() - Apply source-based adjustments"
    echo ""
    echo "## Acceptance Criteria"
    echo ""
    echo "- [ ] calculate_semantic_boost() function implemented in src/classification/ranking.rs"
    echo "- [ ] All 15 tag types have correct boost values assigned"
    echo "- [ ] Multi-tag bonus calculation works correctly"
    echo "- [ ] Context-aware boost adjustments applied for import/export sources"
    echo "- [ ] Unit tests cover all tag types and combinations"
    echo "- [ ] Unit tests verify multi-tag bonus calculation"
    echo "- [ ] Unit tests verify context-aware adjustments"
    echo "- [ ] Edge cases tested: no tags, single tag, multiple tags"
    echo "- [ ] Documentation added with examples"
    echo ""
    echo "## Testing Requirements"
    echo ""
    echo "### Unit Tests Required"
    echo ""
    echo "1. Individual tag boosts: Test each tag type returns correct base value"
    echo "2. Multi-tag scenarios: Test combinations of 2, 3, 4+ tags"
    echo "3. Context adjustments: Test import/export source boosts"
    echo "4. Edge cases: Empty tag vector, single tag, maximum tag combination"
    echo "5. Configurable weights: Test custom boost configurations"
    echo ""
    echo "### Example Test Cases"
    echo ""
    echo "- URL tag should return boost of 25"
    echo "- URL + Domain tags should return 25 + 25 + 3 = 53"
    echo "- ImportName source should add +5 context boost"
    echo "- Empty tags vector should return 0"
    echo "- Single tag should have no multi-tag bonus"
    echo ""
    echo "## Dependencies"
    echo ""
    echo "- Blocked by: Ranking System Foundation - need RankingEngine struct and configuration"
    echo "- Related to: Classification module implementation"
    echo "- Enables: Complete ranking algorithm implementation"
    echo ""
    echo "## Technical Notes"
    echo ""
    echo "- Boost values are based on analytical value for malware analysis and binary reverse engineering"
    echo "- Network indicators (URLs, IPs) receive highest boost as they are often IoCs"
    echo "- Symbol names (imports/exports) are valuable for API usage analysis"
    echo "- Context-aware boosts help prioritize strings found in high-signal locations"
    echo ""
    echo "## Requirements"
    echo ""
    echo "- 5.2: Semantic boost calculation"
    echo "- 5.4: Import/export name boost scoring"
    echo ""
    echo "## References"
    echo ""
    echo "- Ranking Algorithm Documentation: docs/src/ranking.md"
    echo "- Implementation Plan: .kiro/specs/stringy-binary-analyzer/tasks.md - Task 11.2"
    echo ""
    echo "## Task-ID"
    echo ""
    echo "stringy-analyzer/semantic-boost-scoring"
    } > /tmp/issue23_body.md

    Update the issue

    gh issue edit 23 --title "Implement Semantic Boost Scoring for String Ranking" --body-file /tmp/issue23_body.md

    echo ""
    echo "✓ Issue #23 updated successfully"
    echo ""

    View the updated issue

    gh issue view 23

    
    Length of output: 4705
    
    ---
    
    
    
    </details>
    
    @unclesp1d3r I've successfully enhanced issue #23 with comprehensive technical details and a proposed solution. Here's what was updated:
    
    ## ✅ Changes Made
    
    ### Title Enhancement
    - **Before**: "Semantic Boost Scoring"
    - **After**: "Implement Semantic Boost Scoring for String Ranking"
    
    ### Body Enhancements
    
    **Added comprehensive context including:**
    
    1. **Background Section** - Explained how semantic boost fits into the overall ranking formula
    2. **Current State Assessment** - Clear checklist of what's done vs. what's needed
    3. **Detailed Boost Values Table** - All 15 tag types organized by category with specific boost values:
       - Network tags: +25 (Url, Domain, IPv4, IPv6)
       - Identifiers: +20 (Guid, Email)
       - File System: +15 (FilePath, RegistryPath, UserAgent)
       - And more...
    
    4. **Multi-Tag Bonus System** - Explained diminishing returns calculation with examples
    5. **Context-Aware Adjustments** - Symbol context boosts for imports/exports
    6. **Implementation Structure** - Specific method signatures and responsibilities
    7. **Clear Acceptance Criteria** - 9 checkboxes for tracking completion
    8. **Comprehensive Testing Requirements** - 5 categories of unit tests with specific examples
    9. **Dependencies & Technical Notes** - Context for the implementation decisions
    
    ### Metadata
    - **Labels**: Already well-configured (area:analyzer, lang:rust, needs:tests, status:backlog, type:enhancement)
    - **Assignee**: unclesp1d3r ✅
    - **Milestone**: v0.1 ✅
    
    **Note**: I attempted to add a `priority:high` label, but it doesn't exist in your repository's label set. If you'd like to prioritize this issue, you may want to create that label or use an existing priority label.
    
    The issue now provides a complete implementation roadmap with specific boost values extracted from your ranking documentation, making it ready for development!
    
  7. traycerai commented on Nov 10, 2025

    @traycerai

    Warning

    Rate limit exceeded. Please try after 2493 seconds.

  8. unclesp1d3r commented on Jul 4, 2026

    @unclesp1d3r
    MemberAuthor

    Implemented: semantic boost scoring is part of the src/classification/ ranking pipeline. Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions